Creating a Seamless Windows VM Experience on Arch Linux with GPU Passthrough
Virtualization on Linux has become incredibly powerful, allowing users to run a Windows virtual machine (VM) with near-native performance using GPU passthrough. This guide will walk you through setting up an Arch Linux environment with libvirt, configuring a Windows 11 VM, and optimizing it with GPU passthrough for a seamless experience. For optimal results, this setup utilizes two GPUs, which offers a smoother user experience by dedicating one GPU to the host and another to the VM. Key Components
- Two GPUs – While this can technically be done with one GPU, using two makes the process easier and delivers a more seamless user experience.
- 32 GB of RAM – While 16 GB is sufficient, 32 GB ensures that both the host and VM have plenty of memory to handle demanding tasks without bottlenecks.
- Optional: SSD for Windows Installation – For faster boot and load times, consider adding a separate SSD for the Windows VM.
Step 1: Setting up Arch Linux and Hyperland
First, set up Arch Linux and install Hyperland for your window manager. Once done, proceed with setting up libvirt.
Step 2: Installing Necessary Packages
To enable virtualization, install the following packages on your Arch Linux host:
sudo pacman -S qemu libvirt edk2-ovmf virt-manager ebtables dnsmasq
Step 3: Enabling and Starting libvirt Network
Activate and set the libvirt network to start automatically on boot with the following commands:
sudo virsh net-autostart default
sudo virsh net-start default
Step 4: Configuring libvirtd
Edit the libvirtd.conf file to adjust permissions and enable logging.
sudo nano /etc/libvirt/libvirtd.conf
Uncomment the following lines (between lines 80 and 105):
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
Add these lines to the end of the file to enable logging:
log_filters="3:qemu 1:libvirt"
log_outputs="2:file:/var/log/libvirt/libvirtd.log"
Step 5: Adding User to Groups and Enabling libvirtd
Run these commands to add your user to the necessary groups and enable the libvirt daemon:
sudo usermod -a -G kvm,libvirt $(whoami)
sudo systemctl enable libvirtd
sudo groups $(whoami)
Then reboot or log out and log back in to apply the group changes.
Step 6: Configuring qemu.conf
Edit “/etc/libvirt/qemu.conf” to ensure that the correct user has permissions. Replace root with your username:
user = "your_username"
group = "your_username"
Restart the libvirtd service to apply the changes:
sudo systemctl restart libvirtd
Step 7: Setting Up the Windows 11 VM
- Download the Windows 11 ISO file and open Virt-Manager.
- Create a new VM with the following configurations:
- Firmware: OVMF_CODE.secboot.fd
- TPM:
- Type: Emulated
- Model: TIS
- Version: 2.0
- Proceed with the Windows 11 installation and set up networking.
- After installation, install an RDP client (e.g., RustDesk) on both your Linux host and the Windows VM for easy access.
- Install the necessary Virtio drivers on Windows and reboot to enable optimal performance.
Step 8: GPU Passthrough Setup
To enable GPU passthrough, use the following steps:
- Run the QuickPassthrough script from this GitHub project to assist with configuration.
- Reboot your system.
- In Virt-Manager, assign the entire secondary GPU to the Windows VM, and set the VM’s video to None.
Step 9: Configuring Looking Glass for a Seamless Display Experience
Looking Glass is a tool that allows you to display your VM’s output on your host machine. Here’s how to set it up:
-
Install Looking Glass on both the host and VM.
-
Add the following line to the VM’s XML configuration to allocate shared memory for Looking Glass:
<shmem name='looking-glass'>
<model type='ivshmem-plain'/>
<size unit='M'>32</size>
</shmem>
- Edit the Looking Glass configuration file to set the appropriate user permissions:
sudo nvim /etc/tmpfiles.d/10-looking-glass.conf
-
In Virt-Manager, change the “” device to “”.
-
Add necessary peripherals such as a keyboard and mouse to the VM for direct control.
-
Enable audio by adding this line under in the VM configuration:
<sound model="ich9">
<address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
</sound>
<audio id="1" type="spice"/>
Ensure that there is only one audio device with the ID of 1 to avoid errors.
- Remove the “memballoon” device line if it exists:
<memballoon model="none"/>
Step 10: Launching the VM with Looking Glass
After setting up Looking Glass, start the VM and wait about a minute before executing the following command on your host:
looking-glass -f
Once you have Looking Glass running, you can disable the VGA output in Virt-Manager under the video settings to improve performance.
With this setup, you now have a Windows 11 VM running on Arch Linux with GPU passthrough, managed through libvirt, and accessible via Looking Glass for a near-native experience. This setup allows you to take full advantage of both systems’ power without rebooting between operating systems.