2011-08-29

HOWTO: recovering Linux hibernate functionality after modification of the swap partition

If you change the swap partition and forget about adjusting some settings, your GNU/Linux system can lose its hibernate functionality (it will hibernate, but not resume correctly — you'll lose your hibernated session if you boot with your default system settings).
Here follows a quick solution (tested in Debian & Ubuntu).

Assume you've created a new swap partition and listed it in /etc/fstab:
user@machine:~$ cat /etc/fstab | grep swap
UUID=12345678-12ab-cd34-5678-445566778800    none    swap    sw    0    0
You can also get the swap partition UUID with blkid command:
user@machine:~$ sudo blkid | grep swap
[sudo] password for user:
/dev/sda8: UUID="12345678-12ab-cd34-5678-445566778800" TYPE="swap"
Then you need to check and modify resume file to match the UUID of swap partition.
user@machine:~$ cat /etc/initramfs-tools/conf.d/resume
RESUME=UUID=12345678-0000-0000-0000-123456789012
As you can see, the UUID of resume partition is not correct. You can edit that file with any text editor you like (gedit, nano, vi etc.), e. g.:
$ sudo nano /etc/initramfs-tools/conf.d/resume
or
$ sudoedit /etc/initramfs-tools/conf.d/resume
or
$ gksu gedit /etc/initramfs-tools/conf.d/resume
After all these manipulations, it's needed to update the initramfs image (it's usually stored in a file named like 'initrd.img'):
$ sudo update-initramfs -u
Folks say there is an alternative temporary solution based on applying a kernel option like resume=/dev/sda8 (where /dev/sda8 is a hibernate / swap partition), but usually there's no reason to do that (except the urgent manual restoring of the badly hibernated session, at the boot time).

References:
  1. https://help.ubuntu.com/community/UsingUUID

No comments:

Post a Comment