Last active
March 14, 2024 18:12
-
-
Save Berny23/7dac6ba3900621b5b0b5d6205f1d9e4d to your computer and use it in GitHub Desktop.
KVM QEMU Single NVIDIA GPU Passthrough with Kubuntu Host and Windows 11 Guest (/etc/libvirt/hooks/qemu.d/<VM-NAME>/prepare/begin/start.sh)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Helpful to read output when debugging | |
set -x | |
# Stop display manager | |
systemctl stop display-manager.service | |
# Specific to KDE Plasma under Wayland (put your username in here instead of berny23) | |
systemctl --user -M berny23@ stop plasma-* | |
# Remove GPU kernel modules | |
rmmod nvidia_drm | |
rmmod nvidia-uvm | |
rmmod nvidia_modeset | |
rmmod nvidia | |
# Remove mainboard audio controller kernel modules | |
sudo rmmod snd_hda_intel | |
# Unbind VTconsoles | |
echo 0 > /sys/class/vtconsole/vtcon0/bind | |
echo 0 > /sys/class/vtconsole/vtcon1/bind | |
# Unbind EFI-Framebuffer | |
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind | |
# Avoid a Race condition by waiting 2 seconds. This can be calibrated to be shorter or longer if required for your system | |
sleep 2 | |
# Load VFIO Kernel Module | |
modprobe vfio-pci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment