Skip to content

Instantly share code, notes, and snippets.

@jcassette
Created January 6, 2024 18:47
Show Gist options
  • Select an option

  • Save jcassette/91d1fe8086af7a088d938d0aec64d6a6 to your computer and use it in GitHub Desktop.

Select an option

Save jcassette/91d1fe8086af7a088d938d0aec64d6a6 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
set -x
# https://wiki.debian.org/NvidiaGraphicsDrivers#Debian_12_.22Bookworm.22
sudo sed --in-place .bak --expression 's/bookworm main .*$/bookworm main contrib non-free non-free-firmware/' /etc/apt/sources.list
sudo apt update
sudo apt install --assume-yes nvidia-driver firmware-misc-nonfree
# https://wiki.debian.org/SecureBoot#Making_DKMS_modules_signing_by_DKMS_signing_key_usable_with_the_secure_boot
sudo mokutil --import /var/lib/dkms/mok.pub
# https://wiki.debian.org/NvidiaGraphicsDrivers#Wayland
echo 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX nvidia-drm.modeset=1"' | sudo tee /etc/default/grub.d/nvidia-modeset.cfg
sudo update-grub
sudo cp /usr/share/doc/xserver-xorg-video-nvidia/examples/nvidia-sleep.sh /usr/bin
sudo cp /usr/share/doc/xserver-xorg-video-nvidia/examples/system-sleep/nvidia /usr/lib/systemd/system-sleep
sudo cp /usr/share/doc/xserver-xorg-video-nvidia/examples/system/nvidia-* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable nvidia-hibernate nvidia-resume nvidia-suspend
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1" | sudo tee /etc/modprobe.d/nvidia-power-management.conf
# Enroll the DKMS signing key and load the new driver
echo "Please reboot the system"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment