How to Run Windows in a VM with GPU Acceleration on Arch Linux
Categories:
5 minute read
Running Windows in a virtual machine (VM) is a common use case for developers, gamers, and professionals who require access to Windows-specific applications while using Linux as their primary operating system. On Arch Linux, this task can be accomplished with enhanced performance using GPU passthrough, a technique that allows the VM to directly utilize a physical graphics card for near-native speed.
In this guide, we’ll walk you through the complete process of setting up Windows in a VM with GPU acceleration using QEMU/KVM, libvirt, and virt-manager on Arch Linux. We will cover prerequisites, configuration, GPU passthrough, Windows setup, and tips for better performance.
1. Understanding GPU Passthrough
GPU passthrough involves redirecting a physical GPU to a VM using VFIO (Virtual Function I/O). This allows the guest OS (Windows in this case) to communicate with the GPU as if it were running natively. With this method, you can achieve near-native gaming and application performance inside the Windows VM.
This setup is ideal for:
- Gamers who need Windows for games that don’t run well under Wine or Proton.
- Creative professionals who require GPU acceleration for tasks like video editing.
- Developers testing Windows apps on native hardware.
2. System Requirements
To achieve GPU passthrough, ensure your system meets the following requirements:
- CPU with virtualization support (Intel VT-x/AMD-V) and IOMMU support (VT-d/AMD-Vi).
- A discrete GPU for passthrough (NVIDIA/AMD).
- A separate GPU for the host, or onboard graphics (iGPU).
- UEFI firmware (most modern systems use this).
- Arch Linux installed with the latest kernel.
- At least 16 GB RAM and quad-core CPU for smooth operation.
You can verify virtualization support with:
lscpu | grep Virtualization
3. Enabling Virtualization and IOMMU
You need to enable IOMMU in your system’s bootloader.
For Intel
Edit the GRUB config:
sudo nano /etc/default/grub
Add intel_iommu=on
to the GRUB_CMDLINE_LINUX_DEFAULT
line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on"
For AMD
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=on"
Update GRUB and reboot:
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo reboot
Verify IOMMU is enabled:
dmesg | grep -i iommu
4. Installing QEMU, libvirt, and virt-manager
Install the necessary packages:
sudo pacman -S qemu virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat
Enable and start the libvirtd
service:
sudo systemctl enable --now libvirtd
Add your user to the libvirt group:
sudo usermod -aG libvirt $(whoami)
newgrp libvirt
5. Configuring libvirt and Networking
Ensure qemu
uses system mode with KVM acceleration. You can manage virtual networks using virt-manager
or define a bridged network for more complex setups.
Default NAT networking is fine for most use cases.
To enable default network:
virsh net-start default
virsh net-autostart default
6. Identifying and Isolating the GPU
Use lspci
to identify the GPU and audio components:
lspci -nn | grep -i vga
lspci -nn | grep -i audio
Take note of the PCI IDs (e.g., 0000:01:00.0
for GPU and 0000:01:00.1
for audio).
You also need to identify their IOMMU groups:
find /sys/kernel/iommu_groups/ -type l
Make sure the GPU and its associated devices are in their own group.
7. Installing and Configuring VFIO
Install vfio-pci
modules:
sudo modprobe vfio
sudo modprobe vfio_pci
Create a file /etc/modprobe.d/vfio.conf
:
options vfio-pci ids=1002:67df,1002:aaf0
Replace the IDs with your GPU and audio device PCI IDs.
Then blacklist the GPU drivers to prevent the host from using it:
sudo nano /etc/modprobe.d/blacklist.conf
Add lines:
blacklist nouveau
blacklist nvidia
blacklist amdgpu
blacklist radeon
Rebuild initramfs:
sudo mkinitcpio -P
Reboot your system.
8. Creating the Windows VM
Now use virt-manager
to create the VM.
Steps
- Open
virt-manager
. - Click Create a new virtual machine.
- Choose Local install media and provide the Windows ISO.
- Allocate CPU and RAM (at least 4 cores, 8 GB RAM recommended).
- Create a virtual disk (SSD preferred).
- In the final step, check Customize before install.
- Add the PCI Host Device (your GPU and audio device).
- Choose UEFI firmware (OVMF) under firmware settings.
- Add a USB controller, mouse, and keyboard if needed.
9. Installing Windows and GPU Drivers
Begin installation from the ISO as you would on physical hardware.
After Windows installs
- Install VirtIO drivers for disk, network, etc. You can attach a VirtIO ISO from Fedora’s site.
- Install your GPU drivers (NVIDIA/AMD) just like on a normal system.
Important Tip: If Windows disables your GPU (Code 43), it may be due to NVIDIA’s detection of a VM. This can be bypassed with the kvm=off
flag in QEMU or spoofing Hyper-V features.
10. Performance Tweaks and Final Touches
To further enhance performance:
Enable hugepages:
echo 'vm.nr_hugepages=128' | sudo tee -a /etc/sysctl.d/99-sysctl.conf sudo sysctl -p
Pin CPU cores for better isolation.
Use Virtio for disk and network for optimal speed.
Enable IO Threads and multiqueue networking in virt-manager.
11. Troubleshooting Tips
Common issues:
- Black screen: Check if GPU is properly isolated; recheck IOMMU groups.
- Code 43 (NVIDIA): Use
kvm=off
, or patch QEMU. - No audio: Pass through the GPU’s audio device and install drivers.
- Input lag: Use USB passthrough for keyboard/mouse or use looking-glass.
For better input/output performance and low latency, consider Looking Glass (a software that lets you view and control the VM without a monitor connected to the GPU).
12. Conclusion
Running Windows with GPU acceleration on Arch Linux using QEMU and VFIO is a powerful way to leverage hardware virtualization. It enables you to retain the productivity and flexibility of Linux while gaining the performance of native Windows applications and games.
While the setup is complex and requires careful planning, the end result is a robust and high-performance dual-environment system tailored for power users. Whether you’re a gamer, developer, or multimedia creator, this method can be a game-changer.
Always keep your Arch system and virtual machine tools updated, and don’t hesitate to explore advanced topics like PCIe ACS patching, dual boot hybrid setups, or Thunderbolt GPU passthrough in future experiments.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.