Turbulent Sky
Tech Tips, Tricks and Solutions

For many years I’ve enjoyed the reliability of the Ubuntu/Kubuntu Linux hibernate functionality (just the opposite of Windows). However, today it actually failed. When I powered up the system, it didn’t resume from the swap file. Instead, it just booted up as if I had previously killed the power.

Upon checking into the problem, I noticed that the UUID for the swap partition had changed. I don’t know why. After much hunting and trial-and-error, I was able to reinitialize the swap partition, update the necessary config files and get the system to resume from hibernate once again.

1. First, you need to know the /dev path to your swap file (e.g. /dev/hda2). If you don’t know what it is, take a look inside the /etc/fstab file. In the recent versions of Ubuntu, there is a comment above each device’s UUID entry to tell you what path it points to. Look for a line with

UUID=a-bunch-of-letters-and-numbers none swap sw 0 0

On the line above it should be a comment that says what partition it is (e.g. # /dev/hda2)

Now, armed with that information, do the following:

2. sudo mkswap /dev/your-swap-partition
For /dev/your-swap-partition, fill in the swap partition path you found in the /etc/fstab file. This will reinitialize your swap partition and create a new UUID. Copy down the new UUID (e.g. copy it to the clipboard).

3. sudo gedit /etc/fstab
Look for the same UUID= line from step #1 (the one for your swap partition). Replace the existing UUID value with the new one that you copied in step #2. Then, save the file.

4. sudo gedit /etc/initramfs-tools/conf.d/resume
Replace the old UUID value that appears after RESUME=UUID= in the file with the new value from step #2. Save.

5. cd /dev/disk/by-uuid
This directory contains symlinks from UUIDs to actual partitions.

6. sudo rm your-old-UUID
Enter the old UUID for the swap partition in place of your-old-UUID. This will remove the old, incorrect symlink.

7. sudo ln -s ../../your-swap-partition your-new-UUID
Now, create a new symlink from your swap partition to the new UUID.

8. sudo swapon -va
This will mount the swap partition based on the UUID settings you entered. If it succeeds, you didn’t make any mistakes. If it fails, then you need to verify that you have the correct UUID and partitions in the steps above.

9. sudo update-initramfs -u
This will create a new initramfs image. When it’s done, you’ll be able to hibernate and resume again.

That was a really weird problem. Thanks to a combination of techniques from these two sources, I was able to get it back to normal:

Suddenly my swap drive was missing
Kubuntu Edgy: swap failed when awaken from hibernate

Liked it? Share it!
  • del.icio.us
  • Digg
  • email
  • Facebook
  • FriendFeed
  • Google Bookmarks
  • Reddit
  • Slashdot
  • Twitter
  • StumbleUpon
  • Yahoo! Buzz

Post a comment

7 Comments

  1. Ben says:

    thanks for the nice guide. i spent a couple hours this morning trying to fix this, and all the other forums i looked at included SOME of these steps, but not all. but, everything seems to be working now. i should note that after i completed the steps outlined here, i had to reboot normally once BEFORE trying to initiate hibernate. when i tried hibernating right away, it annihilated my swap again.

  2. Peter Ridge says:

    You’re welcome, Ben. Glad it helped. Thanks for the tip on rebooting. I didn’t need to but apparently others might so thanks for the feedback.

  3. Sebastan says:

    Thanks for this description,Ben! You made my day!!
    Wasn’t able to resume for months now, as i did not find the init-ramfs configuration…

    And now it works again! :-))

  4. anno says:

    Hi!

    Finally! Got it to work. I so much prefere UUID over old hda/sda notation. With a 9 disk ATA+SATA+External Controller environment it is so hard to tell when which disk is what device.

    So, also for me, some time after install sdg1 moved to sdi1 but resume parameter in initramfs was not updated.

    For me although it as enough to replace resume parm with current UUID from swap and update-initramfs.

    Lesson learned: try to move from sda/hda references to UUID only.

  5. Bobby says:

    Thaks a LOT! I am new Ubuntu/Linux user (2days). Created partition and small swap. I had created a new one (2GB), used gparted, LiveCD… everything was ok, only Hibernation not. I read many sites but only Yours has helped me :-)
    Exactly points 4 & 9 missed in my elaboration. THX

  6. Peter Ridge says:

    You’re welcome, Bobby. I’m glad it was helpful. Enjoy your new Ubuntu!

  7. Stas says:

    After I removed the encryption from my home dir and swap resume failed.
    Thanks to your guide I can hibernate again.

    BTW, perhaps as systems progress I noticed that on Ubuntu 9.10 I could skip
    steps 5,6 and 7. I guess mkswap takes care of the things in those steps.

    Anyway thanks again.

Post Comment

Please note: Comments are moderated by an Admin and may not be publicly visible right away.


Creative Commons License This work by Peter Ridge is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.
Turbulent Sky Theme by Peter Ridge, based on BlueMod Theme by FrederikM.de