Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christian-korneck/d25114c48e711b63321710c571e5dd5b to your computer and use it in GitHub Desktop.
Save christian-korneck/d25114c48e711b63321710c571e5dd5b to your computer and use it in GitHub Desktop.
virtmanager: switch windows vm boot disk from sata to virtio

I have a Windows 11 23H2 VM with a SATA boot disk running on virtmanager (KVM/Qemu) on Fedora 39 that I want to convert to a virtio disk.

  • in windows install virtio guest tools (download)
  • create cd drive and attach virtio iso (download)
  • shutdown vm
  • in virtmanager preferences, enable xml editing
  • in the vm disk settings, go to the xml tab, backup the existing xml and change it:

old:

  <disk type="file" device="disk">
  <driver name="qemu" type="qcow2" discard="unmap"/>
  <source file="/var/lib/libvirt/images/win11_01.qcow2"/>
  <target dev="sda" bus="sata"/>
  <address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>

new:

  <disk type="file" device="disk">
  <driver name="qemu" type="qcow2" discard="unmap"/>
  <source file="/var/lib/libvirt/images/win11_01.qcow2"/>
  <target dev="vda" bus="virtio"/>

upon saving, virtmanager will auto-complete this to something like:

<disk type="file" device="disk">
  <driver name="qemu" type="qcow2" discard="unmap"/>
  <source file="/var/lib/libvirt/images/win11_01.qcow2" index="2"/>
  <backingStore/>
  <target dev="vda" bus="virtio"/>
  <alias name="virtio-disk0"/>
  <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
</disk>
  • start disk. windows will boot into a bluescreen, reboot automatically and boot into the recovery menu
  • in the recovery menu, open a cmd shell
  • navigate to the cd drive where the virtio iso is mounted (i.e. d: and load the driver)
cd /d d:\viostor\w11\amd64
drvload.exe viostor.inf
  • now the windows disk should be accessible as c:\ (or a different drive letter)
  • inject the driver to the windows disk:
dism.exe /image:c:\ /add-driver /driver:viostor.inf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment