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.

Here is a great comparison table.

related packages:

TuxOnIce

feisty kernels patched for TuxOnIce:

download.tuxfamily.org/3v1deb/dists/fei...

codetitle. kernel options

initrd_suspend_mode=suspend2
resume2=/dev/hda3

µswsusp

blog.paulbetts.org/index.php/2007/02/11.../

codetitle. kernel options

initrd_suspend_mode=uswsusp
resume=/dev/hda3

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