Weird question: Can you make a Windows VM bootable?

So here’s the deal: I have a primarily Linux machine with Windows installed in a QEMU/KVM VM. It’s got GPU pass-through and all that jazz. I’ve only ever used this Windows installation in the VM, but after experiencing various issues with it that I don’t really want to go into here I thought it might be useful if I could add the ability to boot straight into the Windows installation via grub.

Although it’s a VM I do have it installed on its own drive at least–not using qcow or something like that–which is obviously a prerequisite. So this feels like it should be possible, but is it a good idea? Has anyone done something like this before?

And how would you go about configuring grub for something like this? I did try the “os-prober” command to see if it even detected the Windows install and it did not.

Give it a go, have a look at your Grub’s boot options…

Depending on your distro, the update-grub command that the system runs when it does some updates, may already have found the windows drive and added it to Grub’s list of bootable options?

Not sure if it will boot/work well though, as the image used for KVM would have a lot virtualised of hardware, which would not exist on a bare metal boot.

So the installed Windows drive would be expecting a virtualised CPU, but discover it has been “changed” to a real one on boot, and the motherboard was a UEFI firmware from the QEMU team, which has now changed to a real motherboard etc.

I assume we’re talking Windows 10?

As long as your boot method (UEFI or Legacy/Bios) matches your PC, It should boot. Windows isn’t going to be happy the first time it does and may restart the first boot attempt after it finds a bunch of “new” hardware. I would just use the boot menu on your PC instead of Grub. Just to make sure it works first.

I can’t see why not.

If you have Windows virtualised via Hyper-V, the windows boot loader can even boot from the VHDX file; booting from a disk that was passed through shouldn’t be a problem - again as long as you’re doing UEFI in both cases and not booting the VM via BIOS emulation which may or may not be present in your motherboard.

You can swap windows installs between physical hardware just fine - it will re-probe when it is shifted and reinstall drivers, etc. and may take a reboot or two to settle down but it works.

Activation will freak out of course.