Windows 10 UEFI Physical to KVM/libvirt Virtual
If anyone else stumbles onto this question, there is another alternative for using a native windows install as a VM in Linux:
- Image the whole device as as per Dylan's accepted answer.
- Run the VM from the raw storage.
I managed #2 above, but it can be quite involved. It becomes quite complex and risk if both Linux and Windows share the same device.
It's only worth the extra effort for various reasons:
- Already have and like a dual boot setup.
- Need to run windows directly on hardware.
- Graphics performance for games (and don't have a motherboard/setup able to do PCI passthrough with 2x GPU, etc).
- Overly sensitive audio applications such as Skype for Business that work poorly through virtualized audio devices.
- Want the convenience of a VM for running other less demanding windows apps like MS office, etc.
There were numerous caveats/workarounds:
- I had a fight getting windows to remain activated as it's obviously tying licenses to hardware. Toil with adding motherboard/BIOS serial numbers, exact CPU model, and storage device serial numbers seemed to help.
- Add udev rules to make Linux/Nautilus/Gnome File manager ignore the windows partitions.
- Due to paranoia (worried windows updates might affect grub/boot setup), I didn't just share my whole raw drive with the VM. Instead:
- I cloned the partition table (GPT) and EFI partition to files, and also created a fake end of device image file.
- Used the loopback driver to treat the cloned images as devices
- Used the MD (multi-device) driver via mdadm linear setup to chain all the needed parts together as a hybrid imaged and raw device for the VM. E.g.
md0
built from<GPT table clone image/loopback> + <recovery raw> + <EFI clone image/loopback> + <windows system raw> + <end of device GPT backup table/loopback>
. - Used gdisk and testdisk to correct/adjust the partition tables as needed.
- 1803 windows 10 update threw in an extra partiton I had to adjust for! New partition appears after installing the Windows 10 April Update. Needed to correct again...
I used a similar setup on a 2nd system, but made my life much, much easier by have 2 seperate storage devices, one for Linux, the other for Windows.