Help on software suspend
This page gathers bits of information about getting software suspend to work in Debian. Because the core system components change rapidly among Debian versions, software suspend works differently on different versions of Debians. This page is divided according to Debian versions from new to old.
For more reading material, see also the links at the bottom of this page about hibernate and suspend.
Debian Jessie and newer (8 and newer)
With systemd, pm-utils and its hooks are not used any more, instead there's systemd-suspend. To suspend use:
With Gnome Shell, by default, suspend action is available with ALT + clicking combination on the shutdown button in the user menu.
Some extensions are available to improve user experience and provide a dedicated suspend button
In KDE Plasma
KDE already has a suspend button in its normal shutdown menu, though it may instead be labelled as "Sleep" in Plasma 5.16 and newer. Cases where it might not appear are if powerdevil or upower aren't installed. systemd is used if available, but it's not required.
Note that if power management is suspended by an application, the system may not suspend automatically, even if configured otherwise in your Energy Saving settings. This is often done by media players, for instance, to keep the screen from dimming. The Battery and Brightness item in your system tray will let you know if power management is suspended, and what process is currently suspending it.
Disable suspend and hibernation
X11 on bookworm
X11 wants to blank the screen out of the box. To prevent, try putting
xset dpms 0 0 0 && xset s noblank && xset s off
For systems which should never attempt any type of suspension, these targets can be disabled at the systemd level with the following:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
To re-enable hibernate and suspend use the following command:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
A modern alternative approach for disabling suspend and hibernation is to create /etc/systemd/sleep.conf.d/nosuspend.conf as
[Sleep] AllowSuspend=no AllowHibernation=no AllowSuspendThenHibernate=no AllowHybridSleep=no
The above technique works on Debian 10 Buster and newer. See systemd-sleep.conf(5) for details.
If you just want to prevent suspending when the lid is closed you can set the following options in /etc/systemd/logind.conf:
[Login] HandleLidSwitch=ignore HandleLidSwitchDocked=ignore
Then run systemctl restart systemd-logind.service or reboot.
More information is available in the manpage: man logind.conf
Debian Wheezy (7)
A very notable change is that HAL is phased out. If you still have the hal package installed, you should remove it or it will interference with pm-utils during suspend.
If the suspend / resume works well on your system, you are lucky and no need to read anything on this page. Or else, the first step to debug is to enable debugging for pm-utils, who control the suspend and resume process.
Enabling Debugging for pm-utils
The log of suspend and resume processes are in file /var/log/pm-suspend.log. It contains moderately verbose information by default. More information can be enabled for debugging by inserting line export PM_DEBUG=true into the beginning of file /usr/lib/pm-utils/pm-functions.
Fixing corrupted video on resume
A very common issue found after the computer resumes is corrupted video (or black screen, or no LCD backlight). The first step is to check whether the system is still running, which can be simply done by pressing the Capslock button and check whether the Capslock LED is changing accordingly. If the system is still running, in most cases we need to add a video quirk for your video card.
Debian now has kernel mode setting (KMS) enabled by default for most Intel, nVidia and ATI video cards. But pm-utils' video quirk does support KMS yet. So in most cases you should try disabling KMS first. The detail steps for your specific video card can be found on the KernelModesetting page.
After disabled KMS, if the video after resume still corrupts, you can try to suspend the system by using some video quirks. Read the manpage of the pm-suspend program for a very detailed explanation of all the quirks available, and try the combinations of them from command-line. If you successfully find one combination of quirks that works for your system, you can add them into /usr/lib/pm-utils/video-quirks to make them permanent. At the same time, please help to file a bug against the pm-utils package with a patch about your changes so it can benefit the mass.
A common issue found on systems upgrading from old versions of Debian is the enabling of quirk-s3-bios freezes the system during suspend. If your system freezes during suspend, check the pm-suspend.log carefully after enabled debugging and make sure quirk-s3-bios is not used.
Kernel testing facility
The kernel has a Suspend testing facility changelog.
Introduce sysfs attribute /sys/power/pm_test allowing one to test the suspend core code. Namely, writing one of the strings below to this file causes the suspend code to work in one of the test modes defined as follows:
- test the freezing of processes
- test the freezing of processes and suspending of devices
- test the freezing of processes, suspending of devices and platform global control methods(*)
- test the freezing of processes, suspending of devices, platform global control methods and the disabling of nonboot CPUs
- test the freezing of processes, suspending of devices, platform global control methods, the disabling of nonboot CPUs and suspending of platform/system devices
(*) These are ACPI global control methods on ACPI systems
Then, if a suspend is started by normal means, the suspend core will perform its normal operations up to the point indicated by given test level. Next, it will wait for 5 seconds and carry out the resume operations needed to transition the system back to the fully functional state. Writing "none" to /sys/power/pm_test turns the testing off.
When open for reading, /sys/power/pm_test contains a space-separated list of all available tests (including "none" that represents the normal functionality) in which the current test level is indicated by square brackets.
The actual message (for googlers) are suspend debug: Waiting for 5 seconds.
Gnome Power Manager Manual - The FAQ is interesting