Power Management

more than one way to sleep a laptop

There are three ways to make a laptop sleepy. Suspend was first, so is in the main kernel trunk, suspend2 is better but can’t get in the kernel. There is a feud between the authors. Although is seems most users greatly prefer suspend2 when they try it out (‘it just works’), it may never make it into the kernel.

  • suspend (aka swsusp): the default in debian and ubuntu.
  • µswsusp: a refactoring of swsusp to be more userspace. Works in many situations where swsusp does not. Now supports encryption and compression for hibernation.
  • TuxOnIce (was suspend2): more features, compresses the save image, supports splashscreen, works with more hardware, supports encryption. Unfortunately, requires patching kernel. www.tuxonice.net

Here is a great comparison table.

related packages:

  • acpi-support (/etc/acpi): Scripts for acpi events, such as lid closure, gain of power, etc. Also, hibernate.sh and sleep.sh scripts.
  • hibernate (/etc/hibernate/): An alternative to acpi scripts. The hibernate script helps you in putting your computer to sleep, using one of the various methods available in the kernel (tuxonice, swsusp, µswsusp).
  • powersaved (/etc/powersave/): Provides battery, temperature, ac, cpufreq (SpeedStep, Powernow!) control and monitoring. Proper suspend to disk/ram and standby by shell hooks that are easy to extend. APM and ACPI machines are supported equally. For laptops as well as for workstations.
  • uswsusp: Userspace command line tools for µswsusp (s2ram, s2disk, suspend-keygen). These are used instead of /sys/power/state


feisty kernels patched for TuxOnIce:


codetitle. kernel options




codetitle. kernel options


getting it working with gnome

When Gnome wants to hibernate or sleep it passes off the job to HAL. HAL will execute the script /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux (or hal-system-power-suspend-linux, depending on which action was taken)

The script hal-system-power-hibernate-linux tries to find a library to perform the actual sleeping. It searches in this order, using the first one it finds:

/usr/sbin/pm-suspend (does not exist in debian)
/usr/bin/powersave (package powersaved)
/usr/sbin/hibernate -F/etc/hibernate/ram.conf (package hibernate)
/etc/acpi/sleep.sh (package acpi-support)
/usr/sbin/s2ram (package uswsusp)
/usr/sbin/pmi (package powermangement-interface)
echo "mem" > /sys/power/state (fallback)

So, if you want uswsusp to work, you need to make sure none of the others are installed. Unfortunately, you can’t removed powermanagement-interface because this will remove gnome. Instead, you can divert the pmi script so that it can’t find it:

sudo dpkg-divert --rename --divert /usr/sbin/pmi-disabled /usr/sbin/pmi

This will rename pmi to pmi-disabled, even after you update the powermanagement-interface package. To remove the diversion, run this:

sudo dpkg-divert --rename --remove /usr/sbin/pmi

encryption and hibernation

If your swap is encrypted using /dev/random as the key, then you will not be able to hibernate normally. When the computer boots next, the key will be different and the image you have saved of the previous state will be garbled.

How to get around this?

laptop mode tools

The laptop-mode-tools package can be used to spin down the hard drive during periods of inactivity.

apt-get install laptop-mode-tools

Then edit /etc/laptop-mode/laptop-mode.conf.

further reading

Improved ways to suspend and hibernate a laptop under Linux
Install suspend2 on debian
HOWTO: Suspend2 in Breezy