Windows 10 in KVM: change boot disk to Virtio

Solution 1:

All the answers are correct but you may need to perform few additional steps after you have installed virtio drivers. Here are the steps I followed:

  1. Open an elevated command prompt and set the VM to boot into safe mode by typing

    bcdedit /set {current} safeboot minimal

  2. shut-down the VM and change the boot device type to virtio.

  3. boot the VM. It will enter in safe mode.

    Note: In Safe mode all boot-start drivers will be enabled and loaded, including the virtio driver. Since there is now a miniport installed to use it, the kernel will now make it part of the drivers that are to be loaded on boot and not disable it again.

  4. in the booted VM reset the bcdedit settings to allow the machine to boot into the Normal mode by typing (in elevated command prompt again):

    bcdedit /deletevalue {current} safeboot

  5. Done.

Solution 2:

A fairly simple answer is provided - and may work in many cases, along with hints at other options. If (like me) you're not able to switch to IDE and forced to use VirtIO, then the following alternative approach might work:

  1. Add the virtio driver ISO to VM.
    • Required: The latest driver ISO can be pulled out of the RPMs found at https://fedorapeople.org/groups/virt/virtio-win/repo/latest/
    • Suggested: Also add the windows 10 DVD/CD ISO and boot form that if Startup repair isn't available to you or failing to load the driver and make the Windows 10 OS volume available.
  2. Use Troubleshoot -> Advanced Options -> Command Prompt either from a failed boot recovery menu or boot off windows 10 DVD/CD and get into a command prompt from repair mode option.
  3. Identify your driver latter mappings via wmic logicaldisk get deviceid, volumename, description
    • In my case virtio-win install ISO (CD-ROM Disc) was assigned to E: Your case will vary!
  4. Load the driver via the CLI e.g. drvload g:\viostor\w10\amd64\viostor.inf.
    • After loading the driver, run wmic logicaldisk get deviceid, volumename, description again.
    • F: was where the windows install became mounted in my case. Your cases will vary!
  5. Use the DISM command to inject the storage controller driver
    • E.g. dism /image:f:\ /add-driver /driver:e:\viostor\w10\amd64\viostor.inf
    • As above, change drive letter assignments according to your own environment.

Avoids needing to fiddle with making special windows boot CDs/Images and 'patches' the actual windows install image on the fly.

Note further:

  • While it's possible to use startup repair, one time I did have problems with the drvload command suggesting a reboot was needed. It didn't seem to load the Windows 10 OS volume and a reboot was pointless since I got stuck back at the startup repair screen needing to load the driver again, hence it was more robust using a Windows ISO to boot.
  • One time, with a hybrid Windows 10 instance I can boot on bare metal, or in qemu/libvirt (using raw storage and virtio), I upgraded while running on bare metal and it messed up my virtio drivers when I next booted virtually. Startup repair and dism in this case worked without needing the Windows 10 install DVD.
  • If you do boot from the Windows Install DVD/ISO, be careful to avoid Windows 10's DVD eagerness to restore or reinstall everything...

Credit for DISM approach: Using dism to add drivers