Boot same Windows on real hardware and in VM

JimP

New Member
Jan 13, 2024
9
1
3
Hi. Thanks for the great product.

I run a Proxmox server, some times I'd like to play games on the same machine. So I installed a real Windows on it.

1) /dev/sda: EFI and LVM partitions for Proxmox-on-Debian. Windows EFI bootloader resides here too (as I see it mounted at /boot/EFI. GRUB has detected Windows installation with os-prober and boots it quite good;

2) /dev/sdb: sda1, sda2: some Windows partitions (probably EFI copy too). sda3: main Windows installation. sda4: external LVM storage for Proxmox, also always mounted. What I did: just installed Windows on /dev/sdb and then shrank the partition.

So what and how should I pass through to the Windows VM to be able to boot the same installation both on real hardware and in VM? I'm not able to pass the whole /dev/sdb, but I do need EFI partition somehow be used.

Would you please give me an advice? I promise I'll summarize the result for the wiki.
 
Last edited:
  • Like
Reactions: Jim Holcomb
I once managed this with FreeDOS without (U)EFI. AFAIK, Windows really does not like hardware changes and (U)EFI will probably complicate it even more.
Note that its an ESP partition, not an EFI partition. The boot order is saved in EFI variables (virtual EFI disk) and the bootloaders are stored on the ESP partition.
I do think you need to passthrough the whole drive (like FreeDOS).
 
https://wiki.archlinux.org/title/EFI_system_partition
[The EFI system partition (also called ESP) is an OS independent partition that acts ....]

> The boot order is saved in EFI variables
I thought it is saved in NVRAM variables in BIOS or so-called BIOS

Windows for sure will survive two sets of drivers, but that's not the case. How can I boot it from the real second drive? How to conscruct a drive for Windows with EFI partition and content partition?
 
https://wiki.archlinux.org/title/EFI_system_partition
[The EFI system partition (also called ESP) is an OS independent partition that acts ....]

> The boot order is saved in EFI variables
I thought it is saved in NVRAM variables in BIOS or so-called BIOS
That's what I mean with "EFI variables" ; they are indeed stored by the motherboard so-called BIOS, yes.
Windows for sure will survive two sets of drivers, but that's not the case.
Nice to know I overestimated the driver issues with WIndows.
How can I boot it from the real second drive? How to conscruct a drive for Windows with EFI partition and content partition?
The ESP partition (and content) is already on the real drive, right? You want to boot the same Windows as your real machine does, or am I wrong? Do this with whole disk passthrough: https://pve.proxmox.com/wiki/Passthrough_Physical_Disk_to_Virtual_Machine_(VM) (or PCIe passthrough with a NVMe device).

Add a virtual EFI disk (not actually a disk but that how Proxmox stores the the NVRAM) to your VM in Proxmox.
I guess you need to rescue boot Windows (with the Windows installer ISO maybe?) and repair the Windows boot sequence from within the VM to fix the "virtual NVRAM". I hope this does not break the bare-metal boot process of your Windows. I would expect this to be similar to moving a drive with an installed Windows to another computer (and there might be guides on the internet).

I have little experience with Windows myself, sorry. If it's WIndows 11 you'll might need to add a virtual TPM to the VM if you have this on the bare-metal and enabled. TPM on Windows 11 might interfere with your goals because it is used to prevent tampering with the hardware (as you are doing).
 
Last edited:
> The ESP partition (and content) is already on the real drive, right?
Yep, but there are two: /dev/sda1 (/boot/efi FAT), where the windows EFI bootloader resides, and I don't know what is on /dev/sdb1, where Windows was installed (the whole /dev/sdb and then shrank). Anyway I'm unable to pass the whole /dev/sdb to the Windows VM.

> I hope this does not break the bare-metal boot process of your Windows
I don't care if it breaks, I'd like to reuse the hardware sometimes and may be reinstall properly

I see that there's no ready solution, and this interferes with Proxmox industrial use, but anyway. Thanks for the reply, if I success I will report.
 
> The ESP partition (and content) is already on the real drive, right?
Yep, but there are two: /dev/sda1 (/boot/efi FAT), where the windows EFI bootloader resides, and I don't know what is on /dev/sdb1, where Windows was installed (the whole /dev/sdb and then shrank). Anyway I'm unable to pass the whole /dev/sdb to the Windows VM.
I only now see the complication: Windows divided its boot sequence over more than one drive.
Maybe reinstall WIndows on a single drive (by removing everything else temporarily or using another computer), then it would probably much easier.
> I hope this does not break the bare-metal boot process of your Windows
I don't care if it breaks, I'd like to reuse the hardware sometimes and may be reinstall properly
If you don't care about also booting the same Windows bare-metal, then why all the trouble? Can't you just install it fresh inside a VM (with virtual drives)? Maybe I'm missing something (again), apologies if I am dense.
 
Can't you just install it fresh inside a VM (with virtual drives)?
Will I then be able to boot it bare metal? What should I provide it as a bare metal drive?

I see /dev/sdb1 is 16 MB "Microsoft ESP partition", ok, we'll leave it as is. And the boot EFI part is /dev/sda1, which is FAT and contains EFI modules.
 
Last edited:
Will I then be able to boot it bare metal? What should I provide it as a bare metal drive?
I don't think you can make a real machine boot from a virtual disk. You can boot a virtual machine from a physical drive. But I though you did not need to do both? I'm getting confused, sorry.
 
Yep! I'd like to boot bare metal Windows in Proxmox for work.
Please install a new Windows on a single drive. And then use disk passthrough (or PCIe passthrough when using a NVMe drive).

Do you want to be able to boot that same Windows (after it works in a Proxmox VM) as bare metal also (later)? If NOT, then maybe converting physical to virtual might be the easiest way: https://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE#Physical-to-Virtual_.28P2V.29
 
Please install a new Windows on a single drive
I have 4T drives and this is too much.

Please install a new Windows on a single drive. And then use disk passthrough (or PCIe passthrough when using a NVMe drive).

Do you want to be able to boot that same Windows (after it works in a Proxmox VM) as bare metal also (later)? If NOT, then maybe converting physical to virtual might be the easiest way: https://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE#Physical-to-Virtual_.28P2V.29
Yep, I'd like too. And it works for the external drive, always.
 
Sorry for hi-jacking the thread.
I'm interested in this as well. I don't have an answer though. I'm worried about TPM and the security-wise features that there might be in place for the bare-metal OS (Windows built on the real laptop). For the encrypted disk, I'd say it's just a matter of passing the disk raw disk or PCIe for NvME.
Any other ideas/worries?
 
For now I have learned that to boot bare-metal Windows from the Proxmox/KVM you'll have to assemble a single block device which contains 1) EFI partition 2) Original disk. You do this assembling /dev/md0 from the loop device with EFI and /dev/sd[x]2 from the real hardware. It boots indeed and works well, but the manual for doing this still needs tuning.

Unfortunately Proxmox does not have "pre-up script" which can be run before a VM starts. So this should somehow be done after boot.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!