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.

migrated from serverfault.com Jan 25 '17 at 18:44

This question came from our site for system and network administrators.

  • 1
    I 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 Jan 25 '17 at 19:06
  • You may do better to consider running the Linux installation in a Windows VM: at least it will avoid licence difficulties. – AFH Jan 25 '17 at 19:09
  • @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 Jan 26 '17 at 16:19
  • @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 Jan 26 '17 at 16:36
6

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.

  • 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 Aug 7 '17 at 1:00
  • 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 Aug 7 '17 at 1:04
  • I used udev to set the correct permissions, but the virtual machine is stuck at the Windows logo. Any ideas? – Kartik Aug 7 '17 at 2:49
  • @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 Aug 7 '17 at 3:36
  • 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 Aug 9 '17 at 3:55
2

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.