Windows 10 in KVM: change boot disk to Virtio

27

16

I have installed a Windows 10 virtual machine using an IDE disk and would now like to change the disk to use the Virtio driver.

For other versions of Windows, the approach in this question seems to be sufficient - How to migrate an IDE VM to a virtio VM?

However with Windows 10, this leads to an INACCESSIBLE_BOOT_DEVICE issue.

I am aware that the preferred approach is the use the Virtio device from the start and install the appropriate virtio driver when prompted. Unfortunately I was having some separate issues with changing the CD in KVM (I couldn't get 2 CDROM devices to work either).

Is there any way to correct this issue without reinstalling?

Similar issue here - https://me.m01.eu/blog/2015/03/windows-10-kvm-and-iscsi/#comment-36090

Graeme

Posted 2016-03-27T18:45:54.993

Reputation: 435

+1. I couldn't figure out this issue myself. Following various workarounds for previous versions of Windows, I tried installing the VirtIO driver on the Windows VM after plugging in a VirtIO block device, but I still got INACCESSIBLE_BOOT_DEVICE blue screen. I ended up reinstalling on a VirtIO boot device. – Deltik – 2016-03-27T19:01:03.580

Because I’m lazy, I’ll post it as a comment for you to verify: Add an additional disk, with virtio “controller”. Install driver when Windows asks you to. No need to create partitions or anything. Then switch the boot disk to virtio. Because a controller driver instance is now installed (very important), it should work. – Daniel B – 2016-03-31T18:53:38.553

@DanielB: That's exactly what I did. It appears that your suggestion works for previous versions of Windows, but not Windows 10. – Deltik – 2016-04-01T08:01:13.623

Hm, okay. Well I guess then I have the single best way not to solve your problem (lol): Just modify the Windows ISO and include the drivers. Keep in mind it needs to remain bootable. That way you can (hopefully) install straight to virtio. – Daniel B – 2016-04-01T21:21:01.940

1@DanielB: The VirtIO driver can be loaded in the installation process with a separate driver disc. If Windows 10 is installed with the VirtIO driver, there is no problem. It's just that the existing instructions on the Internet to switch Windows from IDE to VirtIO do not work for Windows 10 KVM virtual machines. – Deltik – 2016-04-03T10:51:27.460

@Deltik I know that. The OP however didn’t succeed in adding two optical drives to his VM. Of course, that could probably also be solved. – Daniel B – 2016-04-03T11:02:13.960

@DanielB, thanks for the tip. I later worked out that the CDROM related problems that I was having was a result of me using SCSI drives. If you use an SCSI drive, the installation will start OK but Windows 10 will then prompt for a driver. The problem I had was with Windows recognising that I had changed the disc, so I couldn't load the driver. Also, if you do two SCSI drives, only one will be recognised. IDE works fine though. Apparently using SCSI for the Windows disc and and IDE for the drivers works too (and gives a faster install). – Graeme – 2016-04-03T13:22:29.667

Answers

27

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.

llegolas

Posted 2016-03-27T18:45:54.993

Reputation: 271

3Fantastic! This was the missing bit for me. I used bcdedit /set safeboot minimal, omitting the {current} because I was not sure what was supposed to go in there. – Charles Green – 2017-10-05T18:13:32.040

2@CharlesGreen {current} is literal, you type in as-is. – Marc.2377 – 2018-02-17T23:09:28.663

Problem if you have PIN login because password login can require network access. I'm reinstalling Windows as a result. https://answers.microsoft.com/en-us/windows/forum/windows_10-security/windows-10-stuck-in-safe-mode-cant-log-in-with-my/d97d04a6-4240-4b80-88e0-e0e64a5bda02#

– Andrew Olney – 2018-02-27T17:35:14.490

I tried with bcdedit /set {current} safeboot network in step one to avoid the logon problem, I also first created a local user to be extra safe and I don't really think the problem applied to me anyway, but since the machine is connected to a domain and I don't have controll of everything I wanted to make sure I didn't do anything wrong. And the network parameter did at least not spoil the process. – HackerBaloo – 2018-08-06T14:23:49.100

how do you do 1), that is, the elevated prompt? – Frederick Nord – 2019-02-07T00:44:28.783

@FrederickNord Run CMD as admin. This exact command doesn't work in PowerShell. Just find CMD in Start and Run as Admin. – neilsimp1 – 2019-02-26T01:39:56.297

1The command I used was bcdedit /set safeboot. Using the suggested "{current}" spits an error. However, I ended up in safe-mode with the requested Virtio-driver, disabled safe-mode and lived happily ever after with a Virtio-disk. – Jari Turkia – 2020-01-24T08:05:47.310

16

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 both windows 10 DVD/CD ISO and virtio driver ISO to VM.
  2. Boot off windows 10 DVD/CD and get into a command prompt from repair mode option.
  3. Load the driver via the CLI e.g. drvload e:\viostor\w10\amd64\viostor.inf
    • In my case e: was where the virtio install ISO got assigned.
    • After loading the driver f: was where the windows install became mounted.
  4. 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, for this niche case, I'd suggest avoiding startup repair (which failed for me). It didn't seem to know how to include vistor.inf after loading it, and if you do try it, be careful to avoid Windows 10's DVD eagerness to restore or reinstall everything...

Credit for DISM approach: Using dism to add drivers

JPvRiel

Posted 2016-03-27T18:45:54.993

Reputation: 871

1Alternative to 4: Right click the inf file -> Install. – rbs – 2017-09-07T10:22:33.653

Also, watch out for windows update breaking this. As per a reddit post, "the update erased my VirtIO drivers": https://www.reddit.com/r/VFIO/comments/6b06y5/no_longer_able_to_boot_into_windows_10_after/. This might happen in the corner case when you run your Windows install as both a dual boot and a VM and apply the update when on native hardware...

– JPvRiel – 2018-01-14T12:12:42.477

1This, plus the answer below. I had to do the boot into Safe Mode (bcdedit /set {current} safeboot minimal) and then remove the Safe Mode boot (bcdedit /deletevalue {current} safeboot), and then restart. After that, it worked with Windows Server 2016 Essentials. – G Trawo – 2018-01-25T19:15:02.060

10

The steps to follow in general are :

  1. Install the VirtIO drivers in the VM
  2. Set the system disk of the VM to use VirtIO
  3. If the VM does not boot, execute Startup Repair or even Repair Install

The procedure in detail is :

  1. Return the boot disk to IDE.
  2. Make sure the windows VM is shutdown.
  3. Download the VirtIO drivers ISO from here.
  4. Mount it on the CD drive for the VM.
  5. Add a storage device which is of the VirtIO type. The size allocation doesn't matter since you are using it to install the drivers.
  6. Start the Windows VM. It will try to install the drivers. If it doesn't, open the Device Manager and you should see the SCSI device listed with the exclamation point icon beside it. You can choose to update the driver and point to mounted ISO's appropriate directory. Once installed, don't reboot but shutdown the machine.
  7. In the virt-manager settings for Windows, change the storage type from IDE to VirtIO.
  8. You can remove the storage device you had created earlier. It is not longer needed.
  9. Start Windows, it should boot up and install the SCSI drivers. You will need to reboot after it does.
  10. If the VM does not boot but the drivers are installed, you might try to do :

    1. Startup Repair that can fix certain system problems that might prevent Windows from starting.
    2. The last solution: Repair Install while booting from the Windows 10 ISO. This will keep all applications and user settings, just refreshing Windows and boot. Use a recent Windows 10 ISO.

If the last step is unfortunately required, one more difficulty that might be encountered is if the Windows boot CD cannot understand the VirtIO disk because these drivers were not included in it by Microsoft. In this case, one needs to create a custom boot CD/USB that contains these drivers, but make sure that you start from a Windows ISO that is of the same level as the installation by getting the latest one (currently 1511).

Here are some tutorials on how to slipstream drivers in Windows :

harrymc

Posted 2016-03-27T18:45:54.993

Reputation: 306 093

This answer would work (and does work for other versions on Windows), except that on step 9, when you try to boot there is an INACCESSIBLE_BOOT_DEVICE error (this is where I was when I posted the question). A startup repair (10.1) does not work and step 10.2 is not actually possible. A repair install can only be done by first booting the system, without the CD, then running setup.exe on the CD. This is what the link in the question describes and as far as I am aware there is no other way to do it. – Graeme – 2016-04-10T12:42:09.847

Exactly what other information am I supposed to supply? I have told you repeatedly that the option isn't there. The problem here is that you continually insist that it is. If it is the case that there are 'dozens of others in various articles found on the Internet', reference one. Link one article that describes how to boot from the CD and start a repair install - without first booting the installed system and running setup.exe on the CD. Link one article from a reliable source that proves you are not outright lying and I will apologise and give you your precious upvote. – Graeme – 2016-04-10T16:45:25.850

See for example this video on how to do Startup Repair on Windows 10 from the installation media. If not, try to use the Command Prompt. As I said above, you might need s slipstreamed ISO - I have no idea if WIn10 installation contains the VirtIO drivers.

– harrymc – 2016-04-10T20:20:04.977

Or you may adapt the drvload method for adding the VirtIO drivers to the booted Windows PE installation image.

– harrymc – 2016-04-10T20:29:57.147

Or you may get a ready-made Win10 ISO with VirtIO (hopefully containing the 1511 update) - this also describes an alternative method to nLite for creating your own custom boot.

– harrymc – 2016-04-10T20:36:40.347

2While the above answer sounds good and looks simple, unfortunately with my VM using the pc-q35-2.5 machine emulation/type, it's not possible to add an IDE controller. – JPvRiel – 2017-04-18T18:08:53.313

6

the answer from harrymc works fine for me.

the following steps I followed:

  1. Install the virtio driver in windows
  2. Add a additional "dummy" virtio disk. Reboot and check if the "dummy" works.
  3. If Step 2 works, then switch the boot disk to virtio.
  4. Reboot
  5. Remove the additional "dummy" virtio disk
  6. ...

sdhd

Posted 2016-03-27T18:45:54.993

Reputation: 61

Please don't add "thanks" as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, which is the Super User way of saying thank you.

– DavidPostill – 2016-06-29T21:19:17.893

1This is an underrated answer - in Proxmox Windows 10 had trouble initializing, even after installing all of the drivers. I had to create a small 1 GB disk as a VirtIO block device, start the VM, verify that it was appearing correctly, and then shut down + change the main drive to VirtIO. Windows 10 didn't correctly detect the HDD driver, so I had to coax it to load it on boot before making the switch. – Albert H – 2018-03-19T05:23:34.670

This is the best answer! I think it could be streamlined though: 1: before booting, add second "dummy" virtio disk 2: boot vm, download drivers, open device manager, update driver for second disk 3: shut down VM, remove second disk, update main disk device type to virtio

https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/

– ThankYee – 2020-01-06T12:49:16.790

3

It is unfortunately possible to have driver perfectly installed and STILL get "inaccessible boot Device." The reason is a bit shocking (I find): a Win 10 installation "remembers" the drivers that were required when it was first installed, and by default WILL NOT load other storage drivers at boot time. This is done, it seems, to "piracy" -- it makes it difficult to run the "same" installation on different hardware. There is some great documentation on this "feature" in this post from the gentoo forums. The essence is as follows:

The Drivers that are targeted for forbidden-to-load-at-boot can be determined as follows: Within the registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services there is one subkey for every driver known to the installation. The name of this subkey is just the name of the driver. Within each driver subkey, there will be a subkey "STARTOVERRIDE" if that driver is to be prevented from loading at boot. In particular, within the STARTOVERRIDE subkey there is a parameter whose name is "0" . IF the value of this parameter is "3", it will not be loaded at boot time. Setting this value to 0 instead will 'override' behavior.

I myself just go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services and search for "STARTOVERRIDE". Each time i find it, if there is name under it called "0" with value "3", I change to "0". This seem to be overkill, you only need to change the drive that needs to load. In my case there are several of them, and I never remember which, so I just do an "F3-search" within that 'services' section.

And one final tip which isn't needed for current, signed, virtio storage, but might be to someone else reading this if they want to use a more experimental driver that is not (yet) signed: I found that EVEN after doing the above trick, I ALSO needed to boot into the advanced options screen and choose F7 ("disable driver signature verification"). Annoyingly, it wasn't enough to set the bcd flag to disable driver verification, because the driver needs to load before the machine reads the BCD and finds out that it doesn't need to verify the signature.

All in all, not Microsoft's most shining hour. You really have to hate your users if you'd rather give legit users a made-up artificial Blue-Screen than allow people to (say) replace a SATA disk with an NVMe disk and have it "just work."

Scott Petrack

Posted 2016-03-27T18:45:54.993

Reputation: 139

Thanks for giving so many details, this is the most workable solution! One regfile to import and solve it all. – Florian Heigl – 2019-11-19T02:12:12.973