Software suspend (Suspend2)

=== Introduction ====

Software suspend is a method of hibernating (Windows style) the current state of the machine so that it can restored later on. For example, you're in the middle of some work on your laptop whilst on the train and need to get off. You can simply press the power button and your laptop will suspend the laptop until you power it on later.

This article covers using Suspend2 in conjunction with hibernate and acpid. It's aimed at laptop users but you could use it on a workstation too, if you so wished.

Some of the file paths, file names etc. may be Debian specific.


Suspend2 has two parts to it: Kernel space and user space

Kernel space

As mentioned, Suspend2 has two parts to it. The kernel space part requires that some code is built in to the kernel. The user space (read: applications) send commands to the kernel which then does the magic.

This article doesn't cover patching, compiling and installing your kernel. There are other articles on the wiki that cover this. You have three options:

After patching your kernel, you will need to change the kernel configuration before compiling.

  Power management options (ACPI, APM)
    --> [*] Suspend2
      --> [*] Swap writer
          (/dev/sda3) Default resume device name

In the above configuration (make menuconfig), I've compiled in Suspend2 support, compiled in the "swap writer" (so the suspended state is written to the swap partition) and finally, told it that the default resume partition is /dev/sda3 which happens to be my swap partition (check what yours is using: grep swap /etc/fstab).

Also compile in the LZF compression algorithm in to the kernel:

  Cryptographic options
     --> [*] LZF compression algorithm

Save, compile, install and boot in to your Suspend2 enabled kernel.

User space

In Debian, the user space interface can be installed via the suspend2-userui package or by compiling them yourself.

Tying it all together

Now we need to use two other utilities to tie everything together and get hibernation to work for us.

The hibernate script

This script handles everything for us. Debian users can install the hibernate package. After installing hibernate, edit /etc/hibernate/hibernate.conf and make sure the following options are enabled and as shown as below:

  <[[NoWiki]]>[[UseSuspend2]]</NoWiki> yes
  Compressor lzf
  <[[NoWiki]]>[[ImageSizeLimit]]</NoWiki> nocache
  <[[NoWiki]]>[[ProcSetting]]</NoWiki> expected_compression 50
  <[[NoWiki]]>[[ProcSetting]]</NoWiki> userui_program /usr/sbin/suspend2ui_text
  <[[NoWiki]]>[[UnmountFSTypes]]</NoWiki> smbfs nfs
  <[[NoWiki]]>[[UnloadBlacklistedModules]]</NoWiki> yes
  <[[NoWiki]]>[[LoadModules]]</NoWiki> auto
  <[[NoWiki]]>[[UpInterfaces]]</NoWiki> auto
  <[[NoWiki]]>[[SwitchToTextMode]]</NoWiki> yes

Hibernate script and ATI

If you're using the ATI drivers then you may find suspend hangs and locks your machine. To fix this, add the following to /etc/hibernate/hibernate.conf:

  <[[NoWiki]]>[[ProcSetting]]</NoWiki> extra_pages_allowance 7500

Hibernate script and NVIDIA

If you're using the NVIDIA drivers then you may need to remove nvidia from /etc/hibernate/blacklisted-modules before suspend will work.


ACPI allows us to trigger a suspend when an event happens, such as the power button being pressed or the laptop lid being closed. You need to have acpid installed and running for this to work. You also need to correct ACPI options in the kernel enabled for certain events.

Edit /etc/acpi/events/powerbtn and change it so it looks like:

  event=button[ /]power

If you want to suspend when the laptop lid is closed, create /etc/acpi/events/lid and enter the following:

  event=button[ /]lid

After making any changes make sure you restart acpid.


That should be everything configured and ready to go. Press the power button and hopefully it'll start the suspend process. You should be able to see this. Once it's saved the current state it will shutdown the machine. Power it back up and it should come out of "hibernation".

Suspend hangs

If suspend hangs, it may be because of several things:

To narrow it down:

Remember you can also bump up the logging level in hibernate.conf and review /var/log/hibernate.log

Suspend doesn't do anything at all

There are normally two reasons for this:

To tackle the first point, turn up the logging level in hibernate.conf and review /var/log/hibernate.log when you trigger an event.

To tackle the second point, tail /var/log/acpid when you press the power button etc. and ensure your kernel is configured for ACPI and the correct ACPI events. Ensure ensure your machine supports ACPI. Older hardware may only support APM.

Other notes

Page written by DavidRamsden

LinuxHints/SoftwareSuspend (last edited 2010-07-25 10:59:00 by AdamTrickett)