Step-by-Step Windows Virtual Machine Creation

This is a step-by-step illustration of the steps mentioned in the Windows QEMU/KVM Virtual Machine on Linux guide. Read the article first before following this guide. The screenshots were taken on Fedora 31.

Created
October 16, 2019
Updated
March 30, 2020

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 a 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 a 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 what 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 the virtual hard disk allows the 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.

In Fedora 32, there is a new OVMF_CODE.secboot.fd option, which enables Secure Boot in the virtual machine. It works without any issue. The only limitation is that all drivers installed in a Windows virtual machine need to be signed by Microsoft or by the Linux distribution in the case of Linux. Secure Boot can be easily turned off later in the UEFI of the virtual machine.

virt-manager new vm use UEFI

The virtual disks (both QCOW2 and RAW) grow when they are filled with data. To also shrink virtual disks after deleting some data, TRIM operation can be used. TRIM/discard 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 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 the Guest Operating System

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

When Installing Linux

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

When Installing Windows

The virtual machine will boot into the installation process.

virt-manager install guest os

Because I used the Virtio SCSI controller for the 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)

Fedora-provided VirtIO drivers are not digitally signed by Microsoft. If you selected UEFI with Secure Boot enabled during the virtual machine creation, you might need to use VirtIO drivers provided by RHEL or CentOS in the virtio-win package, or disable Secure Boot in the UEFI of the virtual machine.

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.