Suspend and hibernate

This article Article description::describes how to suspend or hibernate a Gentoo system.

Kernel
Make sure support for suspend and hibernation has been activated ( CONFIG_SUSPEND ) and ( CONFIG_HIBERNATION ):

Software
The following software can be used for in-kernel default suspend/hibernate implementation, namely, swsusp.

Another alternative is which can be used with swsusp.

Optional: Install upower and consolekit
Some desktop environments might require and ConsoleKit with USE="pm-utils" for showing "Suspend" and "Hibernate" buttons in their menu.

Deploying elogind instead of ConsoleKit
should be installed. should not be installed.

The elogind equivalents for the pm-utils commands pm-suspend, pm-hibernate and pm-suspend-hybrid are as follows, and can be launched as root user or from a user account:

When using elogind instead of ConsoleKit, copy any suspend/resume and hibernate/thaw hook scripts from the directory /etc/pm/sleep.d/ to the directory /lib64/elogind/system-sleep/ and modify them to cater for the new $1 ('pre' or 'post') and $2 ('suspend', 'hibernate', or 'hybrid-sleep'). For example, in the case of elogind a hook script could have the following format:

Available suspend modes
To see available suspend modes use

for swsusp, default implementation.

Those two file will list at least ACPI S2/4 power down methods on modern hardware. New hardware would also support S5 method which is a rough S4 method. ACPI S2 correspond to suspend to ram (ram method in swsusp terms and 3 in ToI terms); S4 hibernation to disk (disk in swsusp terms and 4 in ToI terms; S5 hibernation to disk (5 in ToI terms).

Swsusp users can choose between platfom, meaning ACPI, or *shutdown* methods which can be echo-ed to `/sys/power/disk' sysfs file.

Suspend to RAM
Preferred commands to suspend are:

or

or, if using elogind instead of ConsoleKit

For suspend (to ram) for hibernate-script users:

or

to hibernate (to disk.)

A more raw method is to

Suspend to disk
For suspend to disk to operate a swap partition or swap file must exist.

The swap file should be active beforehand and should be echoed on the appropriate file before any attempt to suspend/hibernate.

A more raw method is to:

Do not forget to probe:

before issuing an actual command and append the result to kernel command line argument prepended with `resume='. This will suffice to resume from a block device or swap file for ToI. However, it's more complicated for a swapfile with swsusp.

Suspend to disk with sys-power/pm-utils
Yet another way to achieve disk hibernation is to use hibernate to swap partition and pm-utils.

First, make sure a swap partition has been set:

For this example, we will assume it's

Edit  and append the resume kernel option to   pointing to the swap partition.

Rebuild the GRUB config:

Update initramfs:

Add the following to /etc/pm/config.d/gentoo (see bug 338239):

Reboot the system:

Next, try

Suspend to disk with sys-auth/elogind
First, make sure a swap partition has been set, grub.cfg rebuilt and the initramfs (if any) updated as shown above.

Reboot the system:

Next, try

Suspend to disk with swapfile
You can use suspend to disk with a swapfile. When you have a functional swapfile you need to configure kernel parameters (via GRUB, etc.).

First find UUID of device where your swapfile resides. For example:.

Find offset of swapfile on given partition using  utility from :

After that edit GRUB config and add required parameters to boot string:

Rebuild GRUB config:

Reboot the system and check used kernel parameters:

It should now be possible to hibernate the system.

Troubleshooting
If troubleshooting suspend the powersave log might be useful:

Also classic kernel buffer comes handy:

Can not resume after suspend
In case resuming from suspend does not work, disable the security chip setting in BIOS/UEFI and try again.

Make sure you change the /etc/pm/config.d/gentoo file as described above.

External resources

 * Suspend and hibernate on wiki.archlinux.org
 * TuxOnIce
 * has been last-rited, see.
 * Linux kernel documentation - swsusp.txt, or the usual location of
 * Gentoo Forums: Suspend and Hibernate with UEFI