How to setup Perfect Windows Virtual Machine On QEMU/KVM
Setup Perfect Windows Virtual Machine On QEMU/KVM
This post will show you how to set up any Windows Based Virtual Machines under QEMU/KVM perfectly, All steps in this post will work for other versions of Windows such as Windows 7,8,10, and Windows Server 2019, 2016, 2008.
(In this post, I will use Windows 10 ISO)
What you will need :
- Any Linux distro.
- QEMU/KVM installed with Virtual Machine Manager on your machine, You can follow these steps in my QEMU/KVM Blog Link to install it.
- Windows 10 ISO, you can find it in here Official Microsoft Webpage
- VirtIO drivers you can find them Here, VirtIO is a virtualization standard for network and disk device drivers.
Overview :
- Installing the Virtual Machine ISO and VirtIO drivers
- Start setting up the VM.
Step - 1: Installing Virtual Machine ISO, VirtIO drivers
You will be asked to choose the Installation Language. Choose your preferred language, then click on Confirm :
Now, you need to choose Windows 10 x64 :
Check Save Option, Then click on OK :
Choose to save the file on the Desktop, Then click on Save:
Install VirtIO drivers:
Choose Stable virtio win ISO file:
Choose Save File option, then click on OK:
Save The File on the Desktop, then click on Save:
Step - 2:
Now the Juicy part begin. First you need to Enable XML Editing for the QEMU/KVM Connection and this will enable you to edit XML configuration of the ISO Image, This done by:
Click on the Connection Bar:
Click on Edit option from the tools bar, then choose Preferences:
From Preferences, check Enable XML Editing box:
Every thing is ready now, So let's start setting up the VM, First click on the plus sign on the right up corner:
Next, choose Local install media (ISO image or CDROM) option, then click on Forward :
Next, Click on Browse to select Windows 10 ISO image :
Click on Browse Local :
(Note: Don't be confused by the list showing in the screenshot, this is my list of previous VMs)
Select Windows 10 ISO from your Desktop Directory, then click on Open :
(Note: I renamed the ISO image, in your side it will have its native name from the website)
Check if Virtual Machine Manager correctly detected the ISO image type :
(Because, Virtual Machine Manager may mis-detect the ISO image type, like in the following screenshot)
In this case, Uncheck Automatically detect from the installation media / source option, then type Microsoft Windows 10 manually, then click on Forward :
Now, Specify how many CPU cores to give to the Vm, And how much RAM to allocate to the Vm then click on Forward :
Recommended specifications for Windows 10 are 4Gb of RAM and 2 CPU cores, feel free to modify them based on your machine specifications, At my end I've chosen to go with the default 4Gb of RAM and 2 CPU Cores.
(Note : QEMU/KVM use dynamic RAM allocation, that mean it will not allocate the Hole Specified RAM space unless it need to)
Specify Desk space, then click on Forward :
(At my end, I went with 50Gb)
Name the Vm (I kept the Default Name), then make sure to check Customize configuration before install box, then click on Finish :
Let's edit CPU XML configuration to optimize CPU usage by reducing its usage from 25% to 3%, choose CPU, then click on XML option :
Delete the first two lines below the <clock offset="localtime"> line :
Change the NO option in <timer name="hpet" present="no"> to yes, then click on Apply:
Click on Memory from the sidebar, then click on Details to back to GUI, then change Current allocation to specify minimum amount of RAM (At my end, I changed the Current allocation to 2Gb, feel free to choose what's suitable with your machine), check Shared Memory box, then click on Apply :
Click SATA Disk 1 from the sidebar, change Disk bus type from SATA to VirtIO option, then click on Apply :
Click on NIC from the sidebar, change Network source to Virtual network "default": NAT, then change Device model to virtio, then click on Apply :
In this post, I configured a NAT interface for the VMs to use. The VMs will not be able to connect to the internet only it will be able to connect to other VMs connect to the same Network, If you want to connect your VM to the internet via Bridge Adapter, visit my Blog about How To Set up Bridge Network on QEMU/KVM.
Now, add new piece of hardware (Storage device), by First click on Add Hardware in the left down corner:
Click on Storage, check Select or create custom storage option, then click on Manage (Choose VirtIO drivers which installed earlier), then specify Device type to (CDROM) option, then click on Finish :
Now, click on Begin installation on the Right up corner :
Installation will begin, Specify Installation language, Time and currency format, Keyboard or input method, for English US leave them as default, then click on Next :
Then click on Install :
You will be prompted to Enter a Product Key, click on I don't have a product key, then click on Next :
Choose Windows 10 Pro version, then click on Next :
Check I accept the license terms box, then click on Next :
Choose Custom installation :
Double-click on Load drivers option, to load VirtIO drivers :
Click OK, to start loading Drivers :
Choose Windows 10 VirtIO driver, then click on Next :
Click on Drive 0 Unallocated Space, then click on Next :

Now, keep following the instruction, and wait until the Installation process ends : 
Let setup VirtIO drivers in the VM to enable NAT connection, open File Explorer:
Click on This PC, then click on CD Drive(E) :

Navigate down in the list, Double-click on virt-io-gt-x64 (VirtIO guest tools for Windows x64 architecture) :

Keep clicking on Next :

Accept the terms, then click on Next :
Click on Yes for the Network Prompt :

Keep in Mind, the Vm will show you that it's not connected to the Internet but, It's connected to the NAT Network (Which mean it's visible to the other VMs in the same NAT network) :
Here, I performed ping to another Device on the same NAT network as the Windows machine, and it's replied :
(192.168.122.22 is Windows Machine IP, 192.168.122.145 is the Other Virtual Machine IP, Keep in mind both Virtual Machines on the Same NAT Network)
In conclusion
setting up Windows 10 on QEMU/KVM is a powerful and versatile solution for running a Windows environment within a virtual machine on your Linux system. This approach allows you to harness the benefits of both operating systems, providing flexibility, security, and efficiency.
By following the steps outlined in this blog, you can seamlessly integrate Windows 10 into your Linux workflow, enabling you to run Windows applications and perform tasks that require Windows without the need for dual-booting or purchasing additional hardware.
Remember to keep your virtual machine optimized for performance, allocate the necessary resources, and ensure that your hardware supports virtualization. With the right setup and a bit of patience, you can enjoy the best of both worlds – the stability of Linux and the familiarity of Windows 10 – all within the comfort of your QEMU/KVM virtual environment.
Happy virtual computing :) !


















































Comments
Post a Comment