Gentoo Suspend/Hibernation

In Linux distros, there are different ways how to suspend and hibernate the desktop computer or laptop. The setup may by easy in some cases but sometimes difficult, based on the distro and requirements you have.

This how-to DOES NOT provide a comprehensive overview of available methods, which can be found, for instance, on the following links:

This manual, however, provides the simpliest way without initramfs nor HAL framework support (KDE>4.6 does not rely on HAL anymore), using the pm-utils method. As the HAL daemon and USE flags are deprecated, only udisks and upower will be focused on.

As the initramfs may seem to be a useful method how to boot up the system (esp. with an encrypted root partion on it), more information can be found here and here.

Kernel Setup Prerequisity

Basically, it is necessary to setup the kernel parameters as follows:

Processor type and features  --->
  [*] Support for suspend on SMP and hot-pluggable CPUs
  [*] Support for hot-pluggable CPUs


Power management options (ACPI, APM)  --->
  [*] Suspend to RAM and standby
  [*] Hibernation (aka 'suspend to disk')
  () Default resume partition
  [*] Run-time PM core functionality
  [*] Power Management Debug Support
  [*]   Extra PM attributes in sysfs for low-level debugging/testing
  [*] Suspend/resume event tracing
  [*] ACPI (Advanced Configuration and Power Interface) Support  --->
    [ ]   Deprecated /proc/acpi files
    [ ]   Deprecated power /proc/acpi directories
       EC read/write access through /sys/kernel/debug/ec
    [*]   Deprecated /proc/acpi/event support
       AC Adapter
    {M}   Button
    -M-   Video
    [*]   Dock
       Processor Aggregator
       Thermal Zone
    (0)   Disable ACPI for systems before Jan 1st this year
    [ ]   Debug Statements
       PCI slot detection driver
    [*]   Power Management Timer Support
    {M}   Container and Module Devices (EXPERIMENTAL)
       Smart Battery System
    -*-   Hardware Error Device
       Allow ACPI methods to be inserted/replaced at run time
    [*]   ACPI Platform Error Interface (APEI)
    [*]     APEI Generic Hardware Error Source
    [*]     APEI PCIe AER logging/recovering support
         APEI Error INJection (EINJ)
         APEI Error Record Serialization Table (ERST) Debug Support
  [*] SFI (Simple Firmware Interface) Support  --->
   APM (Advanced Power Management) BIOS support  --->
    [*]   Enable PM at boot time
      CPU Frequency scaling  --->
  -*- CPU idle PM support
  [*]   Cpuidle Driver for Intel Processors

Cryptographic options  --->
        *** Compression ***
  {*}   Deflate compression algorithm
     Zlib compression algorithm
     LZO compression algorithm
     LZF compression algorithm

You may want to add the above mentioned Initramfs support by:

General setup  --->
    [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
    (/usr/src/initramfs) Initramfs source file(s)

Don’t forget to rebuild any necessary modules after new kernel build by:

module-rebuild rebuild

Suspend Partition Configuration

Edit the /etc/suspend.conf configuration file and update the resume device section based on the current system preferences:

snapshot device = /dev/snapshot
resume device = /dev/sda6
#image size = 350000000
#suspend loglevel = 2
compute checksum = y
compress = y
#encrypt = y
#early writeout = y
#splash = y

Hibernation Configuration

Edit the /etc/hibernate/common.conf configuration file and update with the requested options, e.g.:

SaveClock restore-only
Distribution gentoo
UnmountFSTypes smbfs nfs
UnmountGraceTime 1
FullSpeedCPU yes
GentooModulesAutoload yes

GRUB Legacy Setup

It is necessary to update the kernel line in your GRUB legacy setup (typically, /boot/grub/menu.lst) with the resume statement. The mount point refers to the SWAP partition (sda5 in this example).

kernel /boot/bzImage root=/dev/sda6 resume=/dev/sda5 ro vga=791

Power Management Configuration

Make sure you have installed the following packages (system base):

emerge -vp sys-power/upower sys-fs/udisks

Assuming your are using KDE, it is important to set the acpi and pm-utils USE flags globally in /etc/make.conf and merge pm-utils and powerdevil packages.

emerge -av sys-power/pm-utils kde-base/powerdevil

It’s good to check whether you are in the following groups. Otherwise, think about adding yourself into them.

disk wheel floppy audio cdrom tape video games cdrw usb users vboxusers scanner plugdev wireshark

Not all of them are necessary for the power management process but can be useful in other cases as well.

Now, I suggest to reboot or at least restart the xdm deamon to relogin to X-Windows. Sleep well, if you can, hahahaha…

Notes and Troubleshooting

Do NOT install the sys-power/hibernate-script nor sys-power/suspend since they prevent the sys-power/pm-utils to work properly. For instance, a “log-out procedure” was experienced instead of the “hibernation/suspend-to-disk procedure”.

To make sure, the hibernation is working properly, run as root the following command:

echo disk > /sys/power/state

If it hibernates the computer, then the problem is not in the kernel hibernation option and “somewhere” among the applications or user rights.

This entry was posted in Linux and tagged , , , , . Bookmark the permalink.