Guest User

Untitled

a guest
Feb 21st, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. start.sh
  2. #!/bin/bash
  3. # Helpful to read output when debugging
  4. set -x
  5.  
  6. # Load the config file with our environmental variables
  7. source "/etc/libvirt/hooks/kvm.conf"
  8.  
  9. # Stop your display manager. If you're on kde it'll be sddm.service. Gnome users should use 'killall gdm-x-session' instead
  10. systemctl stop sddm.service
  11.  
  12. # Unbind VTconsoles
  13. echo 0 > /sys/class/vtconsole/vtcon0/bind
  14. # Some machines might have more than 1 virtual console. Add a line for each corresponding VTConsole
  15. echo 0 > /sys/class/vtconsole/vtcon1/bind
  16.  
  17. # Unbind EFI-Framebuffer
  18. echo vesa-framebuffer.0 > /sys/bus/platform/drivers/vesa-framebuffer/unbind
  19.  
  20. # Avoid a race condition by waiting a couple of seconds. This can be calibrated to be shorter or longer if required for your system
  21. sleep 5
  22.  
  23. # Unload all Nvidia drivers
  24. modprobe -r nvidia_drm
  25. modprobe -r nvidia_modeset
  26. modprobe -r nvidia_uvm
  27. modprobe -r nvidia
  28.  
  29. # Unbind the GPU from display driver
  30. virsh nodedev-detach pci_0000_2d_00_0
  31. virsh nodedev-detach pci_0000_2d_00_1
  32.  
  33. # Load VFIO kernel module
  34. modprobe vfio
  35. modprobe vfio_pci
  36. modprobe vfio_iommu_type1
  37.  
  38. stop.sh
  39. #!/bin/bash
  40. set -x
  41.  
  42. # Unload VFIO-PCI Kernel Driver
  43. modprobe -r vfio_pci
  44. modprobe -r vfio_iommu_type1
  45. modprobe -r vfio
  46.  
  47. # Re-Bind GPU to our display drivers
  48. virsh nodedev-reattach pci_0000_2d_00_0
  49. virsh nodedev-reattach pci_0000_2d_00_1
  50.  
  51. # Rebind VT consoles
  52. echo 1 > /sys/class/vtconsole/vtcon0/bind
  53. echo 1 > /sys/class/vtconsole/vtcon1/bind
  54.  
  55. # Read our nvidia configuration when before starting our graphics
  56. nvidia-xconfig --query-gpu-info > /dev/null 2>&1
  57.  
  58. # Re-Bind EFI-Framebuffer
  59. echo "vesa-framebuffer.0" > /sys/bus/platform/drivers/vesa-framebuffer/bind
  60.  
  61. # Load nvidia drivers
  62. modprobe nvidia_drm
  63. modprobe nvidia_modeset
  64. modprobe nvidia_uvm
  65. modprobe nvidia
  66.  
  67. # Restart Display Manager
  68. systemctl start sddm.service
Advertisement
Add Comment
Please, Sign In to add comment