Possible to dual boot *and* virtualize same physical drive containing Windows 10?

11

9

I use Linux as my daily driver, and have just installed Windows 10 to a new physical disk in my PC for dual booting. For a while, I've used Windows 7 through a VirtualBox image I have mounted over iSCSI1.

Now I have two different Windows environments and that's very frustrating. I would love to abandon the Windows 7 VM and access the Windows 10 installation directly through VirtualBox for convenience, but without losing the ability to drop down to dual boot when I need raw-metal performance.

Is it possible to boot an existing installation of Windows 10 on dedicated physical media (internal SATA3 SSD) through VirtualBox without losing the ability to dual boot as well?

If it makes matters more complicated (or impossible) it's worth noting that the Windows 10 SSD is protected with FDE via VeraCrypt.

Chris Tonkinson

Posted 2017-01-25T18:39:52.823

Reputation: 213

1I would love it if it were possible, but I haven't found a way yet. Apart from the problem of running a VM with a physical disc, there are two aspects of switching between hard and virtual boot. (1) There will be major driver reconfiguration whenever you switch run environments. (2) As a corollary, Windows will probably need licence reactivation on each switch: if this is even possible, licensing will almost certainly complain after a couple of reactivations. What you can do is create a virtual disc from a physical installation, but again licensing will be a likely problem. – AFH – 2017-01-25T19:06:39.723

You may do better to consider running the Linux installation in a Windows VM: at least it will avoid licence difficulties. – AFH – 2017-01-25T19:09:19.890

@AFH The license problem can be solved by cloning the host hardware uuid and the disc controller serial ids into the VM. It enables to run Windows once from VM, and once directly (although the m$ licensing still doesn't allow to use multiple installations with the same product key concurrently, so it can be done exclusively in the asked configuration). – peterh - Reinstate Monica – 2017-01-26T16:19:49.833

@peterh - Thanks: I didn't know that UUID cloning was sufficient for Windows licensing. There remains the driver reconfiguration problem on switching. I shall experiment with your answer when I have time. – AFH – 2017-01-26T16:36:59.343

Answers

7

Yes, it is possible.

  1. Configure the virtualbox to use your physical disc. It is a little bit risky, because the VM guest will see your host disc directly. Details here.
  2. Give direct read/write access to yourself to your physical disc (setfacl -m u:yourusername:rw /dev/sda)
  3. Update your virtualbox VM to use the same system uuid as your host (dmidecode -s system-uuid shows your system uuid, vboxmanage modifyvm your-vm-name --hardwareuuid <your-hardware-uuid>). You may need to clone also your drive controller uuids (lsblk --nodeps --no name,serial shows the serial ids of your host. I didn't need to clone them into my virtualbox, but it may be needed. Probably some tricky vboxmanage modifyvm command does it, or you have to edit the vm config xml manually.
  4. Try to set up the same disc and dvd controller types in the VM as your host (if your host is SATA-based, use SATA virtual controllers, if it is IDE based, use IDE ones, etc).

There is another danger: if you boot in a VM your host drive directly, it is possible that you boot the same OS twice. Or you open the same partition twice. This will kill your data, so never mount multiple partitions concurrently. Furthermore, don't mount your NTFS partitions while they are used by your Windows (but you can still share data between your partitions, for example with Samba).

If it accidentally happened, reboot with sysrq (alt+printscreen+b) and fsck everything. Some grub trickery may be also needed for that (I reconfigured grub to boot the windows by default, thus I avoid the problem that I boot accidentally my Linux again inside the Windows VM - and it will surely happen, because Windows Update often restarts your Windows behind your back).

Beware: Win10 uses your system uuid and your drive controller uuids to identify your PC. If you miss (3), your win10 will think it was cloned to a new machine, and it won't be activated any more. Although if you boot back to your original hw, it will be activated again.

peterh - Reinstate Monica

Posted 2017-01-25T18:39:52.823

Reputation: 2 043

I did everything you wrote in your answer, but I am getting an access denied error. I am a little confused, it appears that the setfacl is not holding after reboots. Suggestions? Note: I am not mounting the drive, because I do not want data corruption. ACL documentation says that the drives needing ACL should be included in fstab, which would mount it... – Kartik – 2017-08-07T01:00:45.197

1@Kartik Right, it doesn't hold. The simplest, but a little bit dirty solution is to insert the setfacl command into your /etc/rc.local . The pretty good solution would be to edit it into /etc/udev . I personally don't reboot enough often to make the typing of this command annoying. – peterh - Reinstate Monica – 2017-08-07T01:04:01.883

I used udev to set the correct permissions, but the virtual machine is stuck at the Windows logo. Any ideas? – Kartik – 2017-08-07T02:49:49.540

@Kartik If it can at least start to boot, then the permissions are okay. It has likely nothing to do with this solution, the probable reason is that the windows won't start in the emulated environment (the win can see as if it had been moved into a totally new hardware, so it has to rewire a lot of drivers). Try to start the machine in some degraded more of similar. Or try to turn on some debug modus, or similar. You can handle it as a "windows doesn't boot on new hardware" problem. And try to configure in the vbox the possible most similar hw environtment as you had in the physical machine. – peterh - Reinstate Monica – 2017-08-07T03:36:43.043

1

The failure to boot was caused by update 1703, or the Creator's Update as Microsoft calls it. Rolling back this update fixed the issue. VMs are incompatible with this update. If Windows updated when running on metal, then rolling it back fixes the stuck boot in VM.

– Kartik – 2017-08-09T03:55:13.370

@Kartik Update to your comment from 2020: I can boot win10 in qemu and vbox long-long ago without any problem. – peterh - Reinstate Monica – 2020-01-22T00:32:30.190

Hey, yes, the boot works fine. Though it has been about a half year since I used it too. The only problem is that Windows update might break things from time to time. I now have a PS, and a very powerful machine, so Windows on VM is perfectly fine for me. – Kartik – 2020-01-22T00:40:38.093

1

I succeeded with windows 10 as guest and linux mint as Host.

First you have to unistall all windows 10 updates (just in case, maybe useless) then : Under linux open a console and line by line :

 sudo su

 fdisk -l # looking for EFI et Microsoft basic data for me 1 and 3 of sdb 

 VBoxManage internalcommands createrawvmdk -filename /home/borto/ww10.vmdk -rawdisk /dev/sdb -partitions 1,3 -relative

Add machine in virtual box (always with "sudo virtualbox" to be root) and enable EFI in system tab, and choose windows xp 64 instead of windows 10 else you juste have a beautifull frozen windows 10 flag. That is all.

bormat

Posted 2017-01-25T18:39:52.823

Reputation: 119