VFIO (Virtual Function I/O) allows PCI devices to be passed directly from the host operating system to virtualized guests. Normally, PCI passthrough is used to get neat native performance from graphics cards. Passthrough can also be used with NVMe drives, which use a PCI lane, to get near native hard drive performance. One neat aspect of NVMe passthrough is that the drive can be virtualized or booted natively.
However, there are a few required steps before Windows 7 can be booted from a NVMe drive. Linux, on the other hand, usually includes the necessary drivers and is trivial to setup in comparison.
Intel's reference UEFI implementation is called
tianocore. A qemu supported version of tianocore is provided in most distributions by the
ovmf package. UEFI is needed to boot from a NVMe drive - BIOS implementations don't include support.
# apt-get install ovmf
Build Driver ISO
Windows supports installing drivers from disk during the operating system install. Since Windows 7 is a virtual machine, adding a driver disk is as simple as creating an iso and adding it to the VM. Fedora provides a useful disk image with
virtio drivers which serves as a nice base to add other drivers.
Download the virtio driver disk from Fedora, mount it, and copy the contents to a new directory where the 3rd party drivers can be added:
# mkdir /mnt/loop
# mount /path/to/virtio.iso -o loop /mnt/loop
$ cp -r /mnt/loop/* /home/user/virtio
Samsung NVMe drivers
Samsung's official NVMe drivers only ship as an executable that only runs if a Samsung NVMe drive is detected. There are "pure" driver files floating around the internet. If using a driver downloaded from a third party rings alarm bells, the untrusted drivers can be used to boot Windows on the NVMe drive, which the Samsung installer will detect, allowing trusted drivers to be extracted. It may be a good idea to reinstall Windows 7 after extracting the trusted drivers and copying them to the driver iso.
AMD USB Drivers
Optional, for Ryzen systems that will also boot natively
Windows 7 does not support Ryzen out of the box. The lack of USB support is not a problem if the installation will only be virtualized. However, if the VM will also boot natively then USB drivers need to be installed during the operating system installation.
USB31_PT drivers to the
After copying the necessary drivers to
virtio/ turn it back into an iso:
$ geniso -o virtio.iso virtio/
Setup the Virtual Machine
virt-manager launch the 'New VM' wizard and configure as necessary. Do not enable storage on the fourth pane and make sure to select
Customize configuration before install in the final window.
In the 'Overview' tab select OVMF from the Firmware dropdown menu.
Add the boot media to "IDE CDROM 1" and use the "Add Hardware" dialog to add another CDROM drive with
virtio.iso attached. It is not necessary, but can significantly improve performance, if the CDROM interfaces are changed from
PCI Host Device and select the NVMe drive from the device list:
Apply the configuration changes and boot the virtual machine. If installing Linux, everything should "just work".
Install Windows (and Drivers)
As expected, Windows does not find any disks:
Load Driver and install the NVMe driver:
which will cause the NVMe drive (and any existing partitions) to appear in the installation dialog:
Important: Before continuing with the installation, install the USB drivers (if needed)! The virtio drivers can also be installed at this stage, or from the driver disk after Windows boots.
QXL should probably be installed at this stage
Partition as necessary and carry on with the Windows installer. When it has finished, change the Boot Options of the VM to use the PCI NVMe drive as the boot device:
Start the Windows 7 VMand verify that the SSD is functioning as expected:
> winsat disk -drive C
To boot natively, select the NVMe drive from the "Boot Devices" option of the host motherboard UEFI.
Do you have a lightning fast VM running on an NVMe drive? Is Windows 7 booting natively and as a VM? Say thanks and help keep this site ad & analytic free by using my Amazon Affilliate URL. I'll receive a small portion of any purchases made within 24 hours.