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 uswsuspon arch)
Download and install pm-utils once again, check your repos.
/etc/suspend.conffile, creating it if neccessary. Add your swap partition to the
resume devicefield. For example, my
suspend.conffile 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.conffile and add
uresumein 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/moduleso tha it contains the following:
All done! Now use
pm-suspendto suspend to RAM,
pm-hibernateto suspend to disk and
pm-suspend-hybridto 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…
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.)
acpid, add acpid to the DAEMONS in
Define an event catch in
/etc/acpi/events/named low_battery_warning that looks like
event=battery.* action=/etc/acpi/low_battery_warning.sh %e