Run a Windows VM on a laptop dGPU while the Linux desktop stays on the iGPU.
This repo packages a laptop GPU-passthrough workflow for hybrid graphics systems:
- Linux keeps the integrated GPU for the host desktop.
- A Windows 11 VM receives the NVIDIA dGPU through VFIO.
- libvirt profiles keep safe/debug/GPU modes separate.
- Looking Glass or SPICE can be used as a fallback display path.
- Reboot-time VFIO setup and rollback scripts are included for systems where live switching is unreliable.
It is meant as a reproducible starting point, not a universal one-click installer. Laptop VFIO depends on your exact GPU wiring, IOMMU groups, firmware, and display outputs.
win11-gpu-vfio.sh main VM control script
profiles/ libvirt XML profiles for safe, GPU, and debug modes
boot-vfio-setup.sh stage reboot-time VFIO binding
boot-vfio-revert.sh remove reboot-time VFIO binding
gpu-passthrough-toggle.sh status and mode helper
looking-glass-client.sh launch Looking Glass against the running VM
make-looking-glass-tools-iso.sh
looking-glass-tools/ guest setup note for the generated ISO
- Linux with KVM, QEMU, libvirt, and virt-manager or virsh.
- Hybrid graphics laptop with a host iGPU and a passthrough-capable dGPU.
- IOMMU enabled in firmware.
- A Windows VM or physical Windows disk prepared for libvirt use.
- Optional:
supergfxctlfor supported hybrid graphics mode switching. - Optional: Looking Glass B7 client/host tools.
Useful Arch packages:
sudo pacman -S qemu-full libvirt virt-manager dnsmasq edk2-ovmf bridge-utilsEnable libvirt:
sudo systemctl enable --now libvirtd
sudo usermod -aG libvirt,kvm "$USER"Log out and back in after changing groups.
Clone the repo:
git clone https://github.com/dakshdoesdev/Laptop-VM-GPU-PASSTHROUGH.git
cd Laptop-VM-GPU-PASSTHROUGHCheck current state:
./win11-gpu-vfio.sh statusStart the safe VM profile first:
./win11-gpu-vfio.sh start --safeWhen the safe profile works, try the passthrough profile:
./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh prepare-gpu
./win11-gpu-vfio.sh start --gpuStop and restore the host:
./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh restore-hostUse this when you want to view the Windows VM on the laptop screen instead of relying only on an external monitor.
Install the ACL hook once:
sudo ./install-looking-glass-acl-hook.shGenerate the guest tools ISO:
# Download the Looking Glass B7 host archive from the official project first.
# Save it here as: LookingGlass-Host-B7.exe
./make-looking-glass-tools-iso.shStart the VM with the Looking Glass/SPICE profile:
./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh start --lg
./looking-glass-client.shThe repository does not include LookingGlass-Host-B7.exe or built client binaries. Download/build those locally.
Use this only if live switching cannot move the dGPU to VFIO cleanly.
Stage VFIO boot:
sudo ./boot-vfio-setup.sh
sudo rebootAfter reboot, verify both GPU functions are bound to vfio-pci:
lspci -nnk -s 01:00.0
lspci -nnk -s 01:00.1Rollback:
sudo ./boot-vfio-revert.sh
sudo reboot- Review the XML profiles before importing them.
- Update disk paths, PCI addresses, memory, CPU topology, and firmware paths for your machine.
- Do not run the boot-time VFIO setup until you understand how to revert it.
- Keep a second login path available when testing GPU handoff.
- Do not commit VM disks, ISO images, firmware blobs, logs, or Looking Glass binaries.
The published repo was checked with:
bash -n *.sh
xmllint --noout profiles/*.xml
git diff --check