Skip to content

Instantly share code, notes, and snippets.

@tihmstar
Created May 22, 2026 19:39
Show Gist options
  • Select an option

  • Save tihmstar/d1982258d8d8ebc7c4758275c0fea01f to your computer and use it in GitHub Desktop.

Select an option

Save tihmstar/d1982258d8d8ebc7c4758275c0fea01f to your computer and use it in GitHub Desktop.
Install Windows on 4K blockdev in XEN

Install Windows on 4K blockdev in XEN

1) Prepare drivers image

Note: Make sure to use v9.1.200 or newer!
Download the .zip file, extract it and get the XenTools-x64.msi file from the package folder.
That's the only file we will need from the zip.

1.2) Extract the raw drivers from the zip.

Use the command following command:

msiexec /a XenTools-x64.msi /qb TARGETDIR=C:\XENDRIVERS

to extract the contents of the msi to C:\XENDRIVERS.
Note: Make sure that TARGETDIR specifies an absolute path!
Finally, copy XenTools-x64.msi itself to the directory C:\XENDRIVERS\PFiles64\XCP-ng\Windows PV Drivers\

1.3) Create ISO

Use the following command to create a driver ISO

oscdimg -m -o -u2 -udfver102 "C:\XENDRIVERS\PFiles64\XCP-ng\Windows PV Drivers" C:\XENDRIVERS\WinPEXenPvDrivers.iso

2) Create VM

Create a VM which boots from UEFI (tianocore / EDK2 / ovmf.bin).
Attach a windows installer ISO as well as the ISO created in step 1).
The HDD should use the phy driver and be named xvdz (or anything higher than xvdF) in order to NOT have a QEMU emulated disk.

If you are using libvirt, an example config might look like this:

<domain type="xen">
  <name>testwin10</name>
  <uuid>6d0959c3-628a-41ea-8416-de334495cd72</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">16777216</memory>
  <currentMemory unit="KiB">16777216</currentMemory>
  <os>
    <type arch="x86_64" machine="xenfv">hvm</type>
    <loader readonly="yes" type="pflash">/usr/lib/xen/boot/ovmf.bin</loader>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset="localtime"/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
    <disk type="file" device="disk">
      <driver name="phy" type="raw"/>
      <source file="/var/lib/libvirt/filesystems/vm-testwin10"/>
      <target dev="xvdz" bus="xen"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/Win10_22H2_EnglishInternational_x64v1.iso"/>
      <target dev="hda" bus="ide"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/WinPEXenPvDrivers.iso"/>
      <target dev="hdb" bus="ide"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <controller type="xenbus" index="0"/>
    <controller type="ide" index="0"/>
    <interface type="bridge">
      <mac address="00:16:3e:60:19:06"/>
      <source bridge="br0"/>
    </interface>
    <serial type="pty">
      <target port="0"/>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <input type="tablet" bus="usb"/>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="vnc" port="-1" autoport="yes">
      <listen type="address"/>
    </graphics>
    <video>
      <model type="vga" vram="16384" heads="1" primary="yes"/>
    </video>
    <memballoon model="xen"/>
  </devices>
</domain>

In this example the path /var/lib/libvirt/filesystems/vm-testwin10 is a symlink to a 4K blockdevice.

3) Install Windows

3.1) Boot into Windows installer as usual
Continue in the Windows installer up to the point where you can partition your hard disk. (In Win10 chose "custom install")
You will notice that no disks are available. This is expected. Next you need to load the drivers.
3.2) Load Xenbus and Xenvbd drivers
Click Load Drivers, then Browse, then chose on your disk the path E:\Xenbus and click OK.
You will then be able to install XCP-ng PV Bus (E:\Xenbus\xenbus.inf) driver.
Once done, repeat the procedure to load Xenvbddriver, then you should be able see the HDD and proceed with the installation as normal.
Note: Other drivers are not needed at this point.
3.3) Finish windows installation as normal

4) Post-install PV drivers

4.1) Finish first boot and post-installation setup
4.2) Open (the still inserted) driver ISO that was created in the previous steps and run XenTools-x64.msi, then restart the VM
4.3) Done
You should now have Windows set up on a 4K blockdevice in XEN with PV drivers installed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment