How to install QEMU/KVM and create a Windows 10 virtual machine on Debian
If youāre using Linux, you donāt need VirtualBox or VMware to create virtual machines.
You can use KVM ā the kernel-based virtual machine ā to run both Windows and Linux in virtual machines.
You can use KVM directly or with other command-line tools, but the graphical Virtual Machine Manager (Virt-Manager) application will feel most familiar to people that have used other virtual machine programs.
Virtual machines are amazing for two reasons! They completely defuse the argument over having to choose which operating system to use, because you can use them all.
However, online tutorials are only cool as long as they stay up-to-date, and the reason for this blog entry is that Iāve noticed a lot of KVM tutorials online are around 2017, use old packages, old commands, or are just plain obsolete. This blog post attempts to remedy this by offering a solution that is current for Debian in 2021.
I wanted to install a Windows 10 virtual machine on my Debian build. To begin with, youāre going to need an up-to-date copy of Windows 10 in an ISO. You can download that directly from Microsoft atĀ https://www.microsoft.com/en-us/software-download/windows10ISO
Now open your Terminal.
Can You Go Virtual?
KVM only works if your CPU has hardware virtualization support ā either Intel VT-x or AMD-V. There are two commands that can be run to determine if you have hardware virtualization support.
egrep -c "(svm|vmx)" /proc/cpuinfo
This command will count the number of processor cores that can run svm or vmx virtualization. The resulting answer MUST be higher than 0.
egrep --color -i "svm|vmx" /proc/cpuinfo
This command lists all the processor modes in /cpuinfo and highlights either svm or vmx. If you donāt see at least one of those modes highlighted, abort!
Letās Install QEMU/KVM
Once youāve confirmed that your computer supports virtualization, letās move on to the actual install process.
QEMU/KVM needs libvirt installed to work correctly. Older tutorials advised installing the package libvirt-bin;Ā this package, it seems, no longer exists in Debian repos.
Instead of trying to figure out by trial-and-error which libvirt package to install, weāre going to ignore the libvirt requirement for the moment, and let APT choose which package and version to install
sudo apt install qemu-kvm bridge-utils virt-manager
And it looks like that worked! APT traced the package tree and figured out that we need libvirt0 and will install it to satisfy the dependencies.
Donāt Get More Complicated
Other, older, tutorials Iāve seen advise adding the user to the libvirtd group. However, as weāve already seen, libvirt packages moved on, and it seems libvirtd did too.
There is no need to add your user to the libvirtd group, because there is no libvirtd group, and you donāt need to be a member of this group to run virtual machines.
The only requirement at this point is that you must run any virtual-machine as root or sudo.
When you first run virt-manager, it will ask you to enter your root or sudo password to connect to QEMU/KVM
Installing Windows 10 in a Virtual Environment
Now, down to business!
The Virtual Machine Manager window likely looks like this.
Do what it says. Double Click! Once theĀ āNot Connectedā message goes away, QEMU/KVM is ready to be built and virtualized on.
Right-click on QEMU/KVM and clickĀ āNewā
This will create a New Virtual Machine, that will have QEMU/KVM as its hypervisor.
Remember that Windows 10 ISO we downloaded at the beginning of all this? Weāre going to Browse to find it... and click āChoose Volumeā when itās selected.
This should automatically detect that itās a Windows 10 ISO and select the operating system type below. However, if it doesnāt uncheck the boxĀ āAutomatically detect from the installation media / sourceā and find the operating system you are installing.
You can change your Memory and CPU settings to whatever you prefer at this point. Remember to keep a little in reserve for the host system. I changed mine to 8192 Memory, and 3 CPUās
For Step 4 set up your storage! 40 GiB should be considered a minimum for Windows 10, as Microsoft loves their bloatware!
Step 5 summarizes all the details you entered on steps 1-4.
If this pops up when you hit finish, YES, you need the Virtual Network active...
This brings you to the main configuration screen. ClickĀ āBegin Installationā at the top of the window... Windows 10 will begin installing.
Now we wait...
And wait...
And wait...
Windows 10 takes a long time to install compared to Linux distros doesnāt it?
Making External Connections
So now that Windows 10 is installed, youāll likely need more than just the barebones operating system to do your work.
Would you like to use Zoom? Youāll need a webcam for that, and that means youāll need to connect a USB device into your virtual machine and set-up the webcam.
Need to move files quickly in and out of the virtual machine? Plug a USB stick into the computer, and set up a USB connection in the virtual machine so it can access the USB as a drive.
This all happens after Windows 10 is installed, and the virtual machine has been powered off and is inactive. Your hypervisor QEMU/KVM window should look like this.
Double-click on the Virtual Machine to bring up the Overview / Launcher window.
Here you can change all the initial setup options you made, as well as add new options! On the left-side pane at the bottom of the screen, you will seeĀ ā+ Add Hardwareā. Click that to set up a new USB connection.
Iām going to add my existing webcam from Debian into this virtual machine.
Click USB Host Device on the left side, and find the existing USB device on the right side that you want to add to the virtual machine.
As you can see from the picture, Iām adding my webcam, but the entry right below the webcam is for a SanDisk Cruzer USB stick that I could also add (that would work as an external drive in Windows).
When the device is added, youāll see a new hardware connection in the left-side pane of the virtual machine overview screen.
Switch over to the Graphical Console...
...then click the Play button to start booting your virtual machine and test to make sure the changes you made are working correctly.
















