Suspending and Hibernating on Linux
Note that this post is now outdated, and kept here only for historical reasons.
A simple walkthrough to get hibernate and suspend working on Linux. More a reminder to myself than a walkthrough. Your distro wiki probably has far better instructions for you!
-
Download and install uswsusp. It’s more than likely that your distro already provides it. (For example,
pacman -S uswsusp
on arch) -
Download and install pm-utils once again, check your repos.
-
Edit your
/etc/suspend.conf
file, creating it if neccessary. Add your swap partition to theresume device
field. For example, mysuspend.conf
file looks like this:snapshot device = /dev/snapshot resume device = /dev/sda2 #image size = 350000000 #suspend loglevel = 2 #compute checksum = y compress = y #encrypt = y #early writeout = y #splash = y shutdown method = shutdown
Note how i’ve added a shutdown method and enabled compression.
-
Now, recreate the initramfs. To do this, edit the
/etc/mkinitcpio.conf
file and adduresume
in the HOOKS list before the filesystem hook. Then, run> mkinitcpio -p kernel26
-
Now we need to let pm-utils know that we’ll be using uswsusp. To do that create
/etc/pm/config.d/module
so tha it contains the following:SLEEP_MODULE=uswsusp
-
All done! Now use
pm-suspend
to suspend to RAM,pm-hibernate
to suspend to disk andpm-suspend-hybrid
to suspend to both, which is useful in case of a low battery. If your laptop is anything like mine, you’ll have to invoke it as follows:> sudo pm-hibernate --quirk-dpms-on
You can bind that to a key, etc…
Extras
I want to have my laptop to hibernate whenever the battery gets below a certain level. I like to use ACPID. Setting up ACPID is really distro-specific, but since I use Arch, I’ll go through setting up ACPID on Arch. (This is a reminder to self, after all.)
-
Install
acpi
,acpid
, add acpid to the DAEMONS in/etc/rc.conf
-
Define an event catch in
/etc/acpi/events/
named low_battery_warning that looks likeevent=battery.* action=/etc/acpi/low_battery_warning.sh %e
###Refs: