Step-by-Step Windows Virtual Machine Creation

This is a step-by-step illustration to the Windows QEMU/KVM Virtual Machine on Linux guide. Go read the article first before following this guide. The screenshots were taken on Fedora 31.

October 16, 2019

Create a Virtual Machine

Launch Virtual Machine Manager (virt-manager). Begin a new virtual machine creation wizard.

virt-manager main window

I suppose you have downloaded an Windows installation disk image in the ISO format. If not, download it from the Microsoft website. Note that you may need to run a Windows download tool first if you are accessing the Windows download page from a Windows machine. Accessing the Windows download website from Linux gives you the ISO file directly.

Select the Windows installation ISO file and let the Virtual Machine Manager recognize it as Windows 10 (or change it manually if the automatic recognition fails).

virt-manager new vm select installation media type virt-manager new vm browse installation media virt-manager new vm select installation ISO file virt-manager new vm select operating system

Set the amount of RAM memory to be allocated to the virtual machine. The more, the better. Be careful to leave sufficient amount of RAM to the host operating system. Same with the number of processor cores.

virt-manager new vm select RAM, CPU

Create a virtual hard drive for use in the virtual machine. More space can be allocated than is actually available or used.

virt-manager new vm create virtual hard drive virt-manager new vm create virtual hard drive image

QCOW2 format of virtual hard disk allows a creation of snapshots. RAW format is faster and does not support snapshots.

virt-manager new vm create virtual hard drive parameters virt-manager new vm select a virtual hard drive virt-manager new vm continue with selected hard drive

Check the Customize configuration before install option and click Finish.

virt-manager new vm finish

Unless I have a reason not to, I use UEFI instead of the legacy BIOS option.

virt-manager new vm use UEFI

The virtual disk image (both QCOW2 and RAW) grow when they are filled with data. To shrink them back after deleting some data, TRIM operation must be supported by both the guest operating system and the virtual disk/virtual disk controller.

Virtio SCSI on QEMU supports TRIM. SATA, and IDE emulations do not. Virtio BLK may have added an experimental TRIM support recently.

I use Virtio SCSI, attach the virtual hard drive to it and enable the discard unmap function to pass the TRIM command all the way to the virtual hard drive (and allow its size to be shrunk after deleting data).

virt-manager new vm add VirtIO SCSI controller virt-manager new vm enable TRIM

Change the CPU topology if you wish so. Is there a difference between one dual-core CPU and two single-core ones? Maybe in the guest OS licensing.

virt-manager new vm CPU topology

Install Guest Operating System

After the virtual machine is created, it will start and boot from the installation CD/DVD.

Install Linux

Installing Linux guests is straightforward, no additional drivers are usually needed. Everything should work out of the box.

Install Windows

The virtual machine will boot into the installation process.

virt-manager install guest os

Because I used the Virtio SCSI controller for hard drive and Windows does not have a Virtio SCSI driver, it does not see the virtual hard drive.

The driver can be loaded from the ISO file with the latest VirtIO drivers from Fedora (Windows Guest Drivers page, Fedora VirtIO drivers ISO download)

virt-manager install guest os load drivers virt-manager install guest os load external drivers

Insert the ISO image with the VirtIO drivers and let the installer search for the Virtio SCSI driver for Windows 10.

virt-manager install guest os switch driver ISO virt-manager install guest os browse ISO for drivers virt-manager install guest os select driver virt-manager install guest os missing installation ISO

Insert back the Windows installation ISO image.

virt-manager install guest os insert back installation ISO

Now continue with the installation as usual by selecting the newly-detected virtual hard drive and clicking the Next button. It will create partitions automatically if you leave the space unallocated.

virt-manager install guest os select target partition

Once the operating system is installed, I let it install all updates.

virt-manager install guest os install updates virt-manager install guest os update apps

Install Missing Drivers

If there are any unrecognized devices in the Device Manager, insert back the VirtIO driver ISO and install all missing drivers:

virt-manager install guest os install missing drivers virt-manager install guest os insert driver ISO virt-manager install guest os search for drivers

Install Spice Guest Tools

Download the Windows guest tools (spice-guest-tools) from the SPICE guest tools download page. It will be an EXE file that can be installed on the guest Windows on the Virtual Machine..