Even as a passionate Linux user I prefer Windows for certain tasks (e.g. creating slideshow presentations). For my home machines, I use Linux as my main operating system and have Windows inside a Virtualbox. When I got my laptop from work, it came with Windows pre-installed together with an Office suite and so on. So I decided not to dump that standard installation but, instead, install Ubuntu Linux next to it. But having a Windows installation AND a virtual Windows eats up disk space real quick. Luckily, I found a way to virtualize the Windows installation in Virtualbox. These are the steps I took to get it to work.
Identify the disk¶
First of all, you need to identify the disk on which Windows lives inside your computer. It is important to identify the disk, not the partition. So you need to find out
/dev/sdb, for example, instead of something like
/dev/sdb3. The reason is that during installation Windows (at least Windows 10) creates a bunch of partitions itself, like an EFI partition, a boot partition, and so on.
To spot the device when your Windows-disk is mounted, you can use
If your disk is not mounted, the following command might help
sudo lshw -short -class disk,volume
Of course, you can also fire up
gparted regardless of the mount-state of the disk.
If you have identified the disk, you need to set file system permissions for your account to be able to access the files.
File system permissions¶
Jamie Scaife recommends two alternatives to set up permissions. The first one achieving a higher security level than the second one.
First method: UDEV¶
The first, more secure method involves assigning a dedicated group to the device to which you can add your user account.
First, create a new group
sudo groupadd win10disk
and add your own user to the group
sudo usermod -a -G win10disk youruser
Next, determine the UUID of the Windows disk. The
/dev/sdX of course refers to the block device identifier of your Windows disk.
sudo udevadm info /dev/sdX | grep UUID
This should output something like
which you can then use to fill the newly created file
This will ensure that your block device will have
win10disk as a group entry. You can check this using e.g.
ls -l /dev/sdX after rebooting:
brw-rw---- 1 root win10disk 8, 16 Nov 4 23:33 /dev/sdX
Now, your user should be in the
win10disk group and you should be able to access contents on the block device.
Second method: system-group¶
If you're less interested in achieving a high security level on your machine, you can add yourself to the
disk group. It is most likely the standard group which is already assigned to your block device. Check it with
ls -la /dev/sdX:
brw-rw---- 1 root disk 8, 16 Nov 3 23:36 /dev/sdX
You can see that the standard group is
disk. In case you see something like
root there, you should think twice. Adding your user to the
root group might have unwanted implications...
Creating a VirtualBox Disk Description¶
After identifying the block device and ensuring that your user account has correct access permissions, you need to create a VMDK (Virtual Machine Disk) file that acts as a pointer to the actual block device. This will enable VirtualBox to boot the Windows installation as a guest system.
Create this raw disk image with
VBoxManage internalcommands createrawvmdk -filename /path/to/diskname.vmdk -rawdisk /dev/sdX
This will then output
RAW host disk access VMDK file /path/to/diskname.vmdk created successfully.
Creating the Virtual Machine¶
To virtualize your Windows installation, you just need to create a Virtual Machine inside VirtualBox. Set up a new Virtual Machine as you normally would. However, when you reach the 'Hard disk' section, select to use an existing virtual hard disk file and select the
Finally, if Windows 10 is an EFI install, make sure to
Enable EFI in the
System-section of the configuration of your virtual machine.
Now, you are ready to boot your Windows installation from within Linux :-)
An additional remark regarding the disk block devices.
In my case, the laptop shipped with a single hard drive. That means that I have both the Linux and the Windows installations on the same block device but on different partitions.
I created the VMDK-file representing the hard drive on which the host system lives. And I chose to add my user to the
disk group as I don't know if changing the group of the disk of the operating system has any consequences.
So far, this works. However, booting the virtual machine loads Grub at some point and let's me choose which operating system to boot. I have yet to try to recursively boot Linux again and again ;-)