Here's my problem:

I have a laptop running Arch that I just keep on at home. It's got a good 4 hour battery life, but sometimes my daughter is playing near where it's kept and ends out pulling the plug. Well, when I get home 5 hours later, my laptop had a hard shutdown.

Additionally, sometimes I'll leave it suspended and forget about it for a day or so - same problem.

Here's my proposition:

So my thought was that I could make a cron job that runs every 15 or 30 minutes or something, checking the battery life. If the battery life is < N minutes left, I could just hibernate the laptop. This would work fine if my laptop is in normal 'on'. But if I'm suspended, not so much. So my question is two fold - is there a better way to do this, and if not, is it possible to do some sort of monitoring in suspend mode - basically just run that cron job?

Here's what worked:

Following the uswsusp instructions on the Arch wiki, I installed uswsusp from the AUR. Using the following command:

wayne@jughead:~$ swapon -s
Filename                Type        Size    Used    Priority
/dev/sda2                               partition   530140  56744   -1

I discovered /dev/sda2 was the name of my swap partition. So I set this in my /etc/suspend.conf

snapshot device = /dev/snapshot
resume device = /dev/sda2

I added uresume in my mkinitcpio.conf here:

HOOKS="base udev autodetect pata scsi sata resume uresume filesystems usbinput fsck"

I created /etc/pm/config.d/module and put


in it.

Since my laptop was not recognized (# s2ram --test displayed Machine unknown) I had to use the --force option.

In /usr/lib/pm-utils/module.d/uswsusp I also changed all of the s2ram options to s2both.


1 Answer 1


Sounds like you want suspend-to-both/hybrid suspend which should do all the steps of hibernating, including writing RAM to disk, but not actually turn the machine off; instead, it'll go into S3 (standby). If you wake the machine up before the battery dies, it'll be fairly quick; if the battery dies, it'll be just as if you'd hibernated it.

  • That looks highly promising - I'll be checking that out this evening! Sep 21, 2012 at 16:38
  • Works perfectly! I set it up and yanked the battery and my session came back online. Sep 22, 2012 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .