How To Use Linux KVM To Optimize Your Windows 10 Virtual Machine

This tutorial will demonstrate that KVM and virt-manager are great tools not only to virtualize servers on headless hosts, but also for everyday desktop use. My job duties often require me to have a Windows 10 computer, in order to manage Microsoft specific tasks or software that runs only on Windows. However, I did not want install Windows on any of my hardware so the solution I came up with was to have a Windows 10 Virtual Machine that I can run on my main operating system. This Windows VM allows me to easily move it around differenct computers since I can just a copy-paste the VM files. With a virtual machine, I can also easily create snapshots or backups before testing any new software making it possible to very quickly recover if anything goes wrong.

This tutorial is aimed to new Linux users, or users that are not familiar with KVM hypervisor. I will show you how to create and optimize a Windows 10 virtual machine step by step. If you are looking for the very basics of KVM, I recommend you read my first KVM tutorial, Getting Started With KVM Hypervisor, Virtual Machines The Right Way.

Prerequisites

  • KVM and virt-manager installed. If you need help to get started, you can check my previous article: Getting Started With KVM Hypervisor, Virtual Machines The Right Way.
  • NAT virtual network created
  • virtio iso downloaded from Fedora Downloads Page, and copied in your KVM/libvirt VM storage. Default is usually /var/lib/libvirt/images/
  • Windows iso downloaded and copied in your KVM/libvirt VM storage. Default is usually /var/lib/libvirt/images/

VM Creation

If you already followed my first KVM tutorial, First Steps with KVM hypervisor, you already know how to manage basic tasks with KVM. Let’s go ahead and get started!

Open Virt-Manager, and click on the “+” Icon to create a new VM, and select Local install media. Then, we need to browse to Windows 10 iso. If you downloaded it to KVM default VM storage location, or any of your custom VM storage pools, the .iso file will appear in your selection window. If not, you can always click Browse Local, and select the .iso from your file system. Once .iso is, selected make sure Automatically detect from the installation media source is enabled and that detected operating system is Microsoft Windows 10, then click Forward.

Next up, we need to decide how much horse power we can spare for this Virtual Machine. Remember, Windows 10 is quite power hungry, so assign desired amount of CPU cores and RAM, then click Forward.

Virtual Disk storage requires some attention, as discussed in previous article. First Steps with KVM hypervisor. We need to switch to Select or create custom storage, then click Manage… In the Locate or create storage volume window, click the + icon next to Volumes. Make sure format is qcow2, increase capacity to your preference. For Windows 10, I recommend at least 64GB. Leaving the Allocate entire volume now option unticked, will create a thin provisioned disk. This means that our newly created virtual disk will only take the space that it needs, up to a maximum 64GB. If you prefer to assign the whole 64GB right away, tick this option. Confirm all settings one last time, then go ahead and hit Finish, this will bring us back to previous screen. All we need to do here is select the newly created virtual disk, and confirm by clicking Choose Volume.

Last but not least, we need to make sure we tick customize configuration before install. Then click Finish. This is an important step because by default, Windows VMs lack a few useful features.

Virtual Machine creation with Virtual Machine Manager

Before we can start Virtual Machine installation, we need to take care of a few important steps. First, we need to add virtIO drivers iso, so that we can install storage drivers during installation. Lucky for us, Virtual Machine Manager makes it really easy.

Click on + Add Hardware At the bottom of hardware list, then select Storage, device type CDROM device, bus type SATA, then click Finish. In the new SATA CDROM 2, click on Browse next to Source path, and select your .iso file from the default storage pool. If you saved the .iso file somewhere else, you can also click Browse Local, and pick the .iso file from anywhere in your file system.

Now, we’ll go ahead and enable a feature I find very useful. Move to the Boot Options on left menu. You will notice that we did not apply previous settings, and Virtual Machine Manager is reminding us to do so. Confirm to apply the changes before proceeding. Once previous changes are applied, move to the Boot Options menu, tick the Enable boot menu option, and move SATA CDROM 1 before SATA Disk 1. That means any time we have an .iso file mounted as SATA CDROM 1, it will boot before our local Virtual Disk. Hit Apply to confirm the change.

Virtual Machine customization: Add virtual CDROM and change boot order.

Next, we need to change our default drivers to the paravirtualized virtIO, and add a couple of components to our Virtual Machine to optimize it and enable some nice features.

First, we’ll check our virtual devices, and replace default drivers with virtIO. Select SATA Disk 1, expand Advanced options, and change Disk bus: from SATA to VirtIO, then click Apply.

Then, same thing with our network card: Select NIC :XX:XX:XX, change Device model: to virtio, then click Apply. That’s it for virtIO drivers. We will now add a couple of components to our new Virtual Machine.
Click on + Add Hardware At the bottom of hardare list, then select Channel, device name org.qemu.guest_agent.0, then click Finish.

We also need a VirtIO Console, so let’s add it to our VM. Click on + Add Hardware At the bottom of hardare list, then select Console, device type Pseudo TTY (pty), Type VirtIO, then click Finish.

Virtual Machine customization: virtIO drivers and guest tools.

That’s it, we can now proceed and click on Begin Installation. Windows 10 installation is fairly simple, however there is one step that requires our attention. Remember that we switched our Virtual Disk drivers from SATA to virtIO for performance? Unfortunately Windows .iso images do not include virtIO drivers. We already mounted our second CDROM, with virtIO drivers in our Virtual Machine, so it will be super easy to fix this.

During Windows 10 installation, when prompted Which type of installation do you want?, select second option: Custom: Install windows only (advanced). As you can see, no hard disk is detected. This is because Windows 10 does not include VirtIO drivers. Select Load driver. Browse to your virtIO iso mounted on SATA CDROM 2, open amd64 folder, select w10, and click OK. In the Select the driver to install page, select Red Hat VirtIO SCSI controller, then click Next. As you can see, now the virtual hard disk is detected. Select it and then click Next. That’s it. You can now complete Windows 10 installation.

Windows 10 Setup

Virtual Machine tweaks

On first login after installation, you can see that network card is not available, and that Windows 10 guest VM cannot automatically resize to your Virt-Manager window size. In the View menu, under Scale Display, Auto resize VM with window is greyed out and not available.

Now we will need to install all the VirtIO drivers that are not included with Windows 10. This is going to take some time so bear with me as we go through it all. It is totally worth it, VM performance will improve drastically after we finish. Enough of my ramblings, let’s go ahead. Right click on start menu, and select Device Manager. As you can see, there are many devices that lack drivers. Rick click on first device that needs drivers, and select Update driver. Then, select second option: Browse my computer for driver software. Browse to your virtio iso mounted on SATA CDROM 2, In this case the E:\ drive. Tick the Include subfolders option, then click Next. On the next prompt, Tick the Always trust software from “Red Hat, Inc.”, then click Install. On confirmation window, click Close.

Repeat the same driver installation steps until there are no more devices that lack drivers.
Are we there yet? It appears we need a little bit of patience. We are almost there, I promise! Open your Windows file manager, browse to your VirtIO iso mounted on SATA CDROM 2, in this case the E: drive. open the guest-agent folder, and install qemu-ga-x86_64.

virtIO drivers and guest tools installation.

Last step, open your web browser, open spice website , find Windows binaries, and download spice-guest-tools. Once the download is completed, install spice-guest-tools-latest from your downloads folder. When asked, tick Always trust software from “Red Hat, Inc.”, then click Install. Right click on start menu, select Shut down or sign out > Shut down. NOTE. Restart is not enough, do a full shut down. As you can see in the video below, shut down might take a while. Do not force reset, wait until the Virtual Machine is fully powered off, and you see the Guest is not running. message in Virtual Machine Manager.

Spice guest agent installation.

After power on, go to virt-manager menu View, select Scale Display. Now the Auto resize VM with window option is available. Go ahead and enable it. We did it! Your desktop will resize to virt-manager window size. That took a while but was totally worth it. Last but not least, let’s see if drag and drop between VM host and Windows 10 VM works. I am going to drag a file and confirm it is also working fine.

Before we call it a day, remember to remove the SATA CDROM 2 and also unmount Windows .iso file from SATA CDROM 1.

Feature tests, installation media removal.

Conclusion

Victory! Wow, that took quite a while, compared to a Linux VM that has every driver available and enabled out of the box. But well, this is really useful for people like me that need to have a Windows 10 VM handy for work, school, or other purposes. Since it took us quite a bit of effort, I recommend shutting down the VM and making a few backups, so we won’t have to go through all this any time soon. If you enjoyed this tutorial, you can check my articles in Front Page Linux.

Did you find this tutorial helpful? Let me know in the comments below.

Share this post

Twitter
LinkedIn
Reddit
Threads
Facebook
Email

Comments:

  1. I use Virtualbox since 2009 or so, but I’m looking at KVM and I recently run it in a Virtualbox VM to check the improvements in the GUI of virt-manager. I even run Windows Vista and Ubuntu 14.04 as guests on virt-manager/KVM. I did choose those, because I don’t have to worry about OS updates anymore.

    I have moved my “work” to 5 main VMs, which incudes Windows 10 Pro. In total I have a set of ~50 VMs, but I do a weekly incremental backup/copy to my laptop, so I can run exactly the same software and VMs on my desktop at home and on my laptop on the road.

    That copy operation is based on ZFS “send | ssh receive” and while ZFS is only copying the changed records and not the changed disk image files, that operation is efficient.

  2. This was an amazing article! It gave me some ideas for optimizing my own Win10 VM. Great work!

    Maybe for a follow up, you could show us how to present a graphics card to the VM?

  3. I rely very little on Windows now and so have wondered if VM may be better for me than bare metal, especially given how unreliable I have found Windows update to be, including when dual-booting. Thanks for this guide!

  4. Thank you for this, @ilvipero - the timing is wonderful. Have been dual-booting for far too long and then, I read Tom Warren’s piece on Win11 requirements. I know I didn’t want a type 2 hypervisor, and after a little google-fu, found your article.

Join the discussion at forum.tuxdigital.com

1 more reply

Participants

Avatar for BertN45 Avatar for ITGuyEric Avatar for fabiocosta0305 Avatar for Craigo Avatar for ilvipero Avatar for ak2020