Suspension and hibernation on Linux

Suspension and hibernation on Linux with the pm-utils framework.

Install pm-utils to have four power management modes. Per the manpages for pm-powersave and pm-action, they are:

Puts the computer into low power mode to extend your laptop’s battery runtime.

Most devices are shut down, and system state is saved in RAM. The system still requires power in this state. Most systems require 3 to 5 seconds to suspend or resume, and most laptops can stay in suspend mode for a day or more before exhausting their battery.

System state is saved to disk and the system is fully powered off. The system does not require power, and can stay in hibernate mode indefinitely. Most modern systems require 15 to 45 seconds to hibernate or thaw.

The system does everything it needs to hibernate, but suspends instead of hibernates. If you do not run out of power before restarting, your computer quickly resumes. And if you do run out of power first, your computer thaws.

Once pm-utils has been installed, run the following commands to find out if suspend is supported by your hardware:

$ pm-is-supported --suspend
$ echo $?

An exit code of 0 indicates that suspend is available, and a code of 1 means it is not available.

Repeat the above, substituting –hibernate and –suspend-hybrid for –suspend, to see if the other modes are supported.

To use a supported power mode, simply run one of:


Depending on the packager and distribution, these commands might have to be run as root.

These commands are usually run from a script that is called upon an appropriate condition. For example, I wrote this script to hibernate the computer if a system monitor detects an overheating processor or hard disk:


# Warren Post - GPL v2
# This script is called by gkrellm or another system monitor upon detecting
# that the hard disk or processor is overheating. It sends a mail report  
# to a local user for diagnostic purposes, then hibernates the system.

# Requires: lm_sensors, hddtemp, MTA (e.g. postfix), pm-utils

# lm_sensors output

# Hard disk temperature 
HDDTEMP=`hddtemp -n /dev/sda`

# Top 10 CPU hogs
PS_CPU=`ps -A -o pid,pcpu,state,comm | perl -e '($_ = join "",) =~ s/(\t)/     /g; print;' | sort -g -k 2 -r | head -10`

# Body of email to be sent
EMAIL_BODY="Gkrellm performed an emergency hibernation of this computer when it detected overheating. Relevant diagnostics are:

=== sensors ===


hddtemp -n /dev/sda: ${HDDTEMP}°C

=== Top 10 CPU hogs ===


# Send mail to local user; change username as appropriate
echo "${EMAIL_BODY}" |  mail -s "Emergency shutdown report" warren

# Hibernate box

Hibernation requires swap to be at least as large as RAM, something to remember next time you increase RAM.

man pm-is-supported, man pm-action
Arch Linux wiki: pm-utils
I haven’t tried it, but an alternative package to pm-utils is hibernate


About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

One Response to Suspension and hibernation on Linux

  1. Pingback: System monitoring with Gkrellm | A maze of twisty little passages

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s