Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- start.sh
- #!/bin/bash
- # Helpful to read output when debugging
- set -x
- # Load the config file with our environmental variables
- source "/etc/libvirt/hooks/kvm.conf"
- # Stop your display manager. If you're on kde it'll be sddm.service. Gnome users should use 'killall gdm-x-session' instead
- systemctl stop sddm.service
- # Unbind VTconsoles
- echo 0 > /sys/class/vtconsole/vtcon0/bind
- # Some machines might have more than 1 virtual console. Add a line for each corresponding VTConsole
- echo 0 > /sys/class/vtconsole/vtcon1/bind
- # Unbind EFI-Framebuffer
- echo vesa-framebuffer.0 > /sys/bus/platform/drivers/vesa-framebuffer/unbind
- # Avoid a race condition by waiting a couple of seconds. This can be calibrated to be shorter or longer if required for your system
- sleep 5
- # Unload all Nvidia drivers
- modprobe -r nvidia_drm
- modprobe -r nvidia_modeset
- modprobe -r nvidia_uvm
- modprobe -r nvidia
- # Unbind the GPU from display driver
- virsh nodedev-detach pci_0000_2d_00_0
- virsh nodedev-detach pci_0000_2d_00_1
- # Load VFIO kernel module
- modprobe vfio
- modprobe vfio_pci
- modprobe vfio_iommu_type1
- stop.sh
- #!/bin/bash
- set -x
- # Unload VFIO-PCI Kernel Driver
- modprobe -r vfio_pci
- modprobe -r vfio_iommu_type1
- modprobe -r vfio
- # Re-Bind GPU to our display drivers
- virsh nodedev-reattach pci_0000_2d_00_0
- virsh nodedev-reattach pci_0000_2d_00_1
- # Rebind VT consoles
- echo 1 > /sys/class/vtconsole/vtcon0/bind
- echo 1 > /sys/class/vtconsole/vtcon1/bind
- # Read our nvidia configuration when before starting our graphics
- nvidia-xconfig --query-gpu-info > /dev/null 2>&1
- # Re-Bind EFI-Framebuffer
- echo "vesa-framebuffer.0" > /sys/bus/platform/drivers/vesa-framebuffer/bind
- # Load nvidia drivers
- modprobe nvidia_drm
- modprobe nvidia_modeset
- modprobe nvidia_uvm
- modprobe nvidia
- # Restart Display Manager
- systemctl start sddm.service
Advertisement
Add Comment
Please, Sign In to add comment