Windows 11 Virtual Machine with Virt-Manager and QEMU/KVM
Table of Contents
These are my notes on setting up a Windows 11 VM using virt-manager. This is assuming that virt-manager is already set up; I wrote notes on how to set up virt-manager on Artix Linux here.
Download#
Firstly, obtain a Windows 11 iso. You can download from Microsoft here: https://www.microsoft.com/en-gb/software-download/windows11
Microsoft blocks VPN users from downloading Windows 11. If you are a VPN user, or if you just don’t want to download from Microsoft’s servers, MASSGRAVE is a reputable source of genuine Windows isos.
Secondly, you will need virtio driver isos. You can either download them off the internet here: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/
Alternatively, you may have the virtio-win
package available on your package manager. This will install the
virtio-win.iso
file to /var/lib/libvirt/images
.
Setting up your Windows VM#
Open virt-manager.
Create the VM as usual, but before you click “Finish”, check “Customise configuration before install”.
In the window that pops up:
At “Overview”, set “Chipset” to “Q35” and “Firmware” to “UEFI”.
At “CPUs”, check “Copy host CPU configuration (host-passthrough)”.
Then, still in “CPUs”, check “Manually set CPU topology”. By default, virt-manager creates VMs with each core assigned to the VM as a separate CPU in a separate socket, but Windows Home can only handle one CPU socket, and Windows Pro can only handle two CPU sockets. So we need to manually set the CPU topology.
Set “Sockets” to 1, or if you’re on Windows Pro, you can set it to 2 if you wish. Set “Cores” to the number of vCPUs you’ve allocated to the VM (if you set “Sockets” to 2, it should be half this number, as this is cores per CPU). Set “Threads” to the number of threads per core you want; just set it to 1 if you don’t have a reason to go above that.
Go to the disk, which by default will be “SATA Disk 1”. Set the disk bus to “VirtIO”, the cache mode to “none”, and the discard mode to “unmap”.
At “NIC”, configure your network as you usually do for VMs, but set the “Device model” to “virtio”.
Remove the “Tablet” device.
Under “Display Spice”, make sure the “Type” is “Spice server”, not “VNC server”.
Ensure you have a SPICE channel and a QEMU guest agent channel: one with the name com.redhat.spice.0
, and one with
the name org.qemu.guest_agent
. Add the channels if they don’t exist.
Mount the virtio drivers iso. Click “Add Hardware” at the bottom. Go to “Storage” then set “Device type” to “CDROM
device”. Under “Select or create custom storage”, click “Manage…” and select wherever your virtio-win.iso
is.
Add a TPM chip. Go to “Add Hardware”, then “TPM”. Set the model to “TIS”, and the version to 2.0. Note that you need
the swtpm
package for TPM emulation—either that, or passthrough your real TPM chip.
Now click “Begin Installation”.
Installing Windows 11#
Follow through with the installation until you get to the disk configuration step of the install. Most likely, Windows
11 won’t be able to find your virtio disk due to missing the relevant drivers. Click “Load Driver”, then within the
virtio-win drive, navigate to amd64\w11
and click “OK”. Install the driver. Then install the network driver the same
way at NetKVM\w11\amd64
.
Let Windows install itself. It will then reboot into Windows and prompt you to configure Windows.
Configuring Windows 11#
Follow through the Windows setup until you get to the point where you are asked to log into a Microsoft account. To avoid creating a Microsoft account, in the most recent builds of Windows 11, hit SHIFT + F10. This will open up a command prompt window. Then type the command:
start ms-cxh:local
You’ll get a prompt to “Create a user for this PC”. Proceed to create a local-only user account. You can then continue with the setup using your local account.
Once you’re booted into the Windows desktop, I recommend installing Chocolatey and then the following Chocolatey packages:
Package | Reasoning |
---|---|
qemu-guest-agent |
Serves the same purpose as qemu-guest-agent packages in Linux distros, plus contains full virtio
drivers
|
spice-agent |
SPICE guest drivers to allow for e.g. shared clipboard |
If you don’t want to use Chocolatey, you should install these software “manually”:
-
On the virtio-win drive, execute
virtio-win-gt-x64.msi
in the root directory of the drive. -
Install spice-guest-tools from here: https://www.spice-space.org/download.html
Now let’s enable 3D acceleration. Turn off the VM, and go to the info tab of the VM on virt-manager.
Under “Display Spice”, set “Listen type” to “None”; check “OpenGL”; and set OpenGL to “Auto”.
Under “Video QXL”, set the model to “Virtio”, and check “3D acceleration”.
Boot into the VM.
If visual effects such as rounded corners and transparency are not active, you can edit the registry to enable these
visual effects. Press SUPER + R, then enter regedit
. (Or just type regedit
into the search
bar.)
Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Dwm
. Right-click Dwm
and go to “New”, then
“DWORD (32-bit) Value”. Rename the new registry entry to ForceEffectMode
. Then double-click it and set its value to
2
.
Close regedit and reboot, and the visual effects should be active now.
You can activate Windows for free using MASSGRAVE. Follow the instructions here: https://massgrave.dev/