Skip to content

Instantly share code, notes, and snippets.

@danilw
Last active February 13, 2026 22:16
Show Gist options
  • Select an option

  • Save danilw/000f6aa34f7e950950fa526d25456db1 to your computer and use it in GitHub Desktop.

Select an option

Save danilw/000f6aa34f7e950950fa526d25456db1 to your computer and use it in GitHub Desktop.
Nvidia make suspend work in Linux in Wayland (GNOME)
Nvidia make suspend work in Linux in Wayland (GNOME)
MAIN POINT
adding these kernel boot parameters is enough to save vram on nvidia:
________
Boot grub kernel boot parameters:
nvidia_drm.modeset=1 nvidia_drm.fbdev=1 nvidia.NVreg_TemporaryFilePath="/var/tmp" nvidia.NVreg_PreserveVideoMemoryAllocations=1
________
EVERYTHING ELSE below is only about making custom service
to automatically pause/unpause firefox and gnome desktop to have vram saved correctly
Source:
https://gist.github.com/jstarcher/abdac9c2c0b5de8b073d527870b73a19
https://bbs.archlinux.org/viewtopic.php?pid=2044189#p2044189
additional read section 10
https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks
NOTE0 - AFTER DRIVER UPDATE - if you done this instruction
file /etc/modprobe.d/nvidia.conf will be reseted - after driver update just update this file
to content as in this instruction
that all you need to do after driver update
NOTE - NVreg_TemporaryFilePath=/var/tmp free space at location must be larger
than your VRAM size
NOTE2 - script that do killall -STOP firefox and killall -CONT firefox etc is REQUIRED
if you want to "resume" other GPU app like game - you need to manually "pause" it and "resume"
or add process name to script in similar way as others
NOTE3 - LAPTOP
for laptop case where integrated used
and you do not want to have nvidia running all the time
change to fbdev=0 and modeset=0 in two next sections
________
Edit/create file
/etc/modprobe.d/nvidia.conf
blacklist nouveau
options nvidia_drm modeset=1
options nvidia_drm fbdev=1
options nvidia NVreg_PreserveVideoMemoryAllocations=1
options nvidia NVreg_TemporaryFilePath=/var/tmp
________
Boot grub kernel boot parameters:
nvidia_drm.modeset=1 nvidia_drm.fbdev=1 nvidia.NVreg_TemporaryFilePath="/var/tmp" nvidia.NVreg_PreserveVideoMemoryAllocations=1
________
________
Edit/create file
/usr/local/bin/suspend-gnome-shell.sh
#!/bin/bash
case "$1" in
suspend)
killall -STOP chrome
killall -STOP firefox
killall -STOP gnome-shell
;;
resume)
killall -CONT gnome-shell
killall -CONT chrome
killall -CONT firefox
;;
esac
________
Run below:
sudo chmod +x /usr/local/bin/suspend-gnome-shell.sh
________
________
Edit/create file
/etc/systemd/system/gnome-shell-suspend.service
[Unit]
Description=Suspend gnome-shell
Before=systemd-suspend.service
Before=systemd-hibernate.service
Before=nvidia-suspend.service
Before=nvidia-hibernate.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-gnome-shell.sh suspend
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
________
Edit/create file
/etc/systemd/system/gnome-shell-resume.service
[Unit]
Description=Resume gnome-shell
After=systemd-suspend.service
After=systemd-hibernate.service
After=nvidia-resume.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-gnome-shell.sh resume
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
________
Run below:
sudo systemctl daemon-reload
sudo systemctl enable gnome-shell-suspend
sudo systemctl enable gnome-shell-resume
________
Reboot
OPTIONAL - to block wakeup from keyboard
or when keyboard broken and wakeup automatically (after every boot)
echo PTXH | sudo tee /proc/acpi/wakeup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment