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:
RESUME=/dev/mapper/myvg-swapvol
- 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.
תודה על המאמר, עזר לי ללמוד כמה דברים חדשים
תודה, ושנה טובה
Thanks, not being able to hibernate and resume was driving me mad after I changed to a different swap partition. (I have an old laptop which will not work from the mains, so I use two batteries and charge one while using the other). I thought I had updated the resume destination everywhere, but I didn't know about dpkg-reconfigure uswsusp .
Incidentally, after doing that, pm-hibernate still didn't work for me until I did
sudo update-initramfs -u
Now hibernate and resume work perfectly.