Suspend and hibernate
- 1 Installation
- 2 Available suspend modes
- 3 Suspend to RAM
- 4 Suspend to disk
- 5 Troubleshooting
- 6 See also
- 7 External resources
- 8 References
Make sure support for suspend and hibernation has been activated (CONFIG_SUSPEND) and (CONFIG_HIBERNATION):
Power management and ACPI options ---> [*] Suspend to RAM and standby [*] Hibernation (aka 'suspend to disk')
Using tuxonice-sources is recommended for laptop users who often rely on being able to suspend their laptop and resume work elsewhere.
The following software can be used for in-kernel default suspend/hibernate implementation, namely, swsusp.
emerge --ask sys-power/suspend
Optional: Install upower and consolekit
Some desktop environments might require sys-power/upower and ConsoleKit with USE="pm-utils"  for showing "Suspend" and "Hibernate" buttons in their menu. In case sys-power/upower-pm-utils was installed it must be unmerged.
emerge --unmerge sys-power/upower-pm-utils
emerge --ask sys-power/upower
echo "sys-auth/consolekit pm-utils" >> /etc/portage/package.use
emerge --ask --oneshot sys-auth/consolekit
Available suspend modes
To see available suspend modes use
for swsusp, default implementation.
Or else, probe
/sys/power/tuxonice/powerdown_method sysfs file for ToI.
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 is swsusp terms and 3 in ToI terms); S4 hibernation to disk (disk in swsusp temrs 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.
TuxOnIce can be configured to take over swsusp syspend/hibernation methods. So any command echo-ed to either file will triger the same result.
Suspend to RAM
Preferred commands to suspend are:
For suspend (to ram) for hibernate-script users; or
to hibernate (to disk.)
A more raw method is to
echo mem > /sys/power/state
echo 3 > /sys/power/tuxonice/powerdown_method
for TuxOnIce users. An then
echo > /sys/power/tuxonice/do_hibernate
is necessary to trigger a suspend/hibernation.
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.
echo /dev/sda1 > /sys/power/resume
echo /dev/sda1 > /sys/power/tuxonice/swap/swapfile
for ToI users.
A more raw method is to:
echo disk > /sys/power/state
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
/etc/default/grub and append the resume kernel option to
GRUB_CMDLINE_LINUX_DEFAULT pointing to the swap partition.
Rebuild the GRUB config:
grub-mkconfig -o /boot/grub/grub.cfg
genkernel --install initramfs
Add the following to /etc/pm/config.d/gentoo (see bug 338239):
Reboot the system:
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: /dev/sda1.
If swapfile resides in a LVM volume, GRUB must be compiled with LVM support. Otherwise, the system will not wake up and will be cold started.
Find offset of swapfile on given partition using
swap-offset utility from sys-power/suspend:
After that edit GRUB config and add required parameters to boot string:
Rebuild GRUB config:
grub-mkconfig -o /boot/grub/grub.cfg
Reboot the system and check used kernel parameters:
It should now be possible to hibernate the system.
Remember, swap file must contain all memory used by running processes and memory based filesystems like tmpfs or zram prior to hibernating. However, unless specifically set, the hibernation image is compressed. Setting hibernation image size to half of the amount of installed RAM is a safe value in most cases. One of the cases where this does not fully apply is when the system has a high usage of zswap which means that memory may already be compressed.
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.
- Suspend and hibernate on wiki.archlinux.org
- Linux kernel documentation - swsusp.txt, or the usual location of /usr/src/linux/Documentation/power/swsusp.txt