Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Convert a KVM VM from Legacy BIOS to UEFI with Windows Server 2022

Digital solution partner

Convert a KVM VM from Legacy BIOS to UEFI with Windows Server 2022


In this article, we walk through the successful conversion of a KVM/QEMU virtual machine from Legacy BIOS to UEFI, using Windows Server 2022 as the operating system.

Requirements

  • An existing VM with Windows Server 2022 installed in Legacy BIOS mode
  • Access to the VM’s XML definition file
  • OVMF firmware installed on the host (usually via the ovmf package)

Convert the Disk from MBR to GPT in Windows

Inside the Windows VM, open a command prompt as Administrator and run:

mbr2gpt /convert /allowFullOS

This command converts the MBR partition table to GPT and automatically creates the required EFI partition for UEFI boot.

Modify the VM XML Definition

Shut down the VM and edit the XML with:

virsh edit RDP01

Replace the <os> section with the following UEFI configuration:

<os firmware="efi">
  <type arch="x86_64" machine="pc-q35-8.2">hvm</type>
  <firmware>
    <feature enabled="no" name="enrolled-keys"/>
    <feature enabled="no" name="secure-boot"/>
  </firmware>
  <loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE_4M.fd</loader>
  <nvram template="/usr/share/OVMF/OVMF_VARS_4M.fd">/var/lib/libvirt/qemu/nvram/RDP01_VARS.fd</nvram>
</os>

Create the NVRAM File

If it doesn’t exist yet, copy the VARS template file like this:

mkdir -p /var/lib/libvirt/qemu/nvram/
cp /usr/share/OVMF/OVMF_VARS_4M.fd /var/lib/libvirt/qemu/nvram/RDP01_VARS.fd

✅ Boot and Verify

Start the VM and log into Windows. Open msinfo32 and confirm the boot mode:

  • BIOS Mode: UEFI

Additional Notes

  • No need to manually create EFI partitions: mbr2gpt handles everything.
  • We removed <smbios> to avoid XML validation errors due to missing <sysinfo>.
  • This process also works for Windows 10/11, Server 2016/2019.

The VM is now fully UEFI-compatible and ready for modern deployments!

Posted by Ivan – Synaptica