My laptop's battery had just died. It made me realize how much I depend on it, for changing my working location, either when computer is awake or asleep for many hours. Without a battery, the sleep (aka suspend-to-ram) feature is less useful, for the tiniest power interruption would kill it.
So I had to go back and use the old hibernate feature (aka suspend-to-disk), as powering off-and-on the computer on daily basis is not a reasonable option. But, hibernate never worked for me for quite a while - clicking in my GNOME "System -> Shut Down -> Hibernate" did nothing more than a hard-to-notice flicker. So I had to research this:
- Insight #1: suspending/hibernating from GNOME 2 indirectly triggers the tools: pm-suspend, pm-hibernate (from pm-utils package). Running pm-hibernate manually from a terminal revealed the problem I had by printing the error to screen (and also later I found it in /var/log/pm-suspend.log):
1 s2disk: Could not stat the resume device file. Reason: No such file or directory
- Insight #2: pm-utils make use of uswsusp (userspace software suspend utils): s2disk, s2ram, s2both
- Insight #3: /etc/initramfs-tools/conf.d/resume defines the resume device file (swap device) for the initrd.
- Insight #4: If swap device is a device-mapper device (such as a Logical Volume on LVM) - one should be using RESUME=/dev/mapper/<name>. Notations such as UUID=<ID> or /dev/dm-nn don't seem to work, triggerring the following error on boot:
1234 resume: could not stat the resume device file '# RESUME=/dev/sda6UUID=UUID=038df595-f105-4653-a2a4-7c051f90dd10'Please type in the full path name to try again or pressENTER to boot the system:
- Insight #5: dpkg-reconfigure uswsusp reconfigures the whole thing, and regenerates the initrd (thus applying the newly defined RESUME device).
To summarize, that's how I solved it:
- updated /etc/initramfs-tools/conf.d/resume to:
- Ran dpkg-reconfigure uswsusp
- Tested it by running pm-hibernate
Additional tip: suspend-hybrid is very cool - both writes to disk and RAM: if RAM power survived, wake-up process would be instantaneous. Otherwise, it'll behave as regular hibernate. To use it, simply use pm-suspend-hybrid. GNOME2 doesn't seem to have it in its GUI, I haven't checked GNOME3 out yet.