Resizing Swap Partition Breaks Ubuntu 8.04 Hibernation

Submitted by Eus
on July 27, 2009 - 8:24am

About three weeks ago my employer asked me to shrink the swap partition of a GNU/Linux Ubuntu 8.04 system so as to gain several gigabytes for the root filesystem. After resizing, hibernation failed in a way that although the hibernation process was without any error, turning on the machine again didn't resume the hibernated state. After resizing, the swap space still had enough space for hibernation for sure, and the UUID for the swap space in `/etc/fstab' had been adjusted as well. Just last Friday my employer tried again to solve this problem by googling for information. After a while I got a call, and this time my employer and I found the culprit. Having such an employer is so much fun!

First, my employer tried to install uswsusp following a thread in the Ubuntu forum. After the installation, he tried to run `s2disk' that failed with the following error message:

s2disk: Could not stat the resume device file. Reason: No such file or directory

`s2both' also didn't work with the following error message, which is just the same:

s2both: Could not stat the resume device file. Reason: No such file or directory

So, he called me and had me drill down the problem further. I read the man page of `s2disk' and checked `/etc/uswsusp.conf'. It turned out that the value for key `resume device' was in a wrong UUID. So, I fixed the UUID. But, still the error message about not being able to find the image disk persisted. So, I realized that uswsusp didn't recognize UUID and had to be supplied with `/dev/*'. So, I changed that to `/dev/*'. Now `s2disk' worked. But, when the machine was powered back on, the state was not resumed. So, the hibernation failed. So, my employer suggested to purge uswsusp and install it again. Doing it I saw in the uswsusp installation process the following message:

The swap file or partition that was found in uswsusp's configuration file is not active. In most cases this means userspace software suspend will not work for you and you will need to choose (or let uswsusp choose) another swap space. In some corner cases however, this can be what you want.

Continue without a valid swap space?

Answering `yes' caused the key `resume device' in `/etc/uswsusp.conf' to have a wrong UUID again instead of `/dev/*'. Since the UUID of the swap device listed in `/etc/fstab' was correct, I wondered from where uswsusp got the wrong UUID. After purging and reinstalling uswsusp several times, I realized that update-initramfs was invoked at the end of the installation process provided that I answered `yes' for the question `Continue without a valid swap space?'. So, I went to `/etc/initramfs-tools' and did `ls -r *'. There I saw `resume' under `conf.d'. Seeing its content, I realized that uswsusp had been taking the value for its `resume device' from this file. So, I fixed the content of `resume', purged and installed uswsusp again. This time it was without the error message. Now hibernation worked successfully.

Although I was happy enough with the result, my employer said, "I have a hunch that now the original hibernate should work since it stopped working after the resizing process changed the UUID of the swap space and `/etc/initramfs-tools/conf.d/resume' is not updated to the right UUID." He was right! Now the original hibernate works perfectly and so I purged uswsusp. Heh, I should have got such a hunch myself ;-)

So, I conclude the following points:

1. `/etc/initramfs-tools/conf.d/resume' belongs to the original hibernate function.
2. uswsusp reads `/etc/initramfs-tools/conf.d/resume' to initialize its `resume device' in `/etc/uswsusp.conf'.
3. uswsusp cannot understand UUID format (bug filed: https://bugs.launchpad.net/bugs/404085).
4. gparted changes the UUID of the swap partition although only moving or resizing operation is applied. It should not be like this since resizing a reiserfs filesystem, for example, does not change its UUID. (bug filed: https://bugs.launchpad.net/bugs/404095).

Out of the two bugs, one is solved: gparted bug

on
July 27, 2009 - 8:29am

Hi Ho!

Out of the following two bugs:
1. uswsusp cannot understand UUID format (bug filed: https://bugs.launchpad.net/bugs/404085).
2. gparted changes the UUID of the swap partition although only moving or resizing operation is applied. It should not be like this since resizing a reiserfs filesystem, for example, does not change its UUID. (bug filed: https://bugs.launchpad.net/bugs/404095).

the second bug is already solved:

http://bugzilla.gnome.org/show_bug.cgi?id=575585

Best regards,
Eus (FSF member #4445)

In this digital era, where computing technology is pervasive,
your freedom depends on the software controlling those computing devices.

Join free software movement today!
It is free as in freedom, not as in free beer!

Join: http://www.fsf.org/jf?referrer=4445

I needed another step

Pablo Gil (not verified)
on
September 13, 2009 - 6:58am

Hi there.

Thanks for your post, it put me on the right track to solve my problem (just the same as yours). However, I would like to point out that if you want to make ubunt's built-in hibernation work again, updating /etc/initramfs-tools/conf.d/resume is not enough.

As explained in this Thread, you need to execute 'sudo update-initramfs -u' after in order to effectively use the new UUID.

In your case, as you explained, this command was automatically executed when purging and installing uswsusp. I just wanted to point it out just in case it might save some time to someone.

Yes, you are right!

on
September 16, 2009 - 5:41am

Hi Ho!

Yes, you are right!
Thank you for pointing this matter out :-)

--
Best regards,
Eus (FSF member #4445)

In this digital era, where computing technology is pervasive, your
freedom depends on the software controlling those computing devices.

Join free software movement today! It is free as in freedom, not as in
free beer!

Join: http://www.fsf.org/jf?referrer=4445

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.