Step By Step How to get Hibernate Working for Linux (Ubuntu 11.04, Mint 11)

What Hibernation Is and Does

Hibernation takes all the data in your ram and stores it on your hard drive and then powers down the computer. The data is stored in a special type of partition called a swap partition (you can also have a swap file). When you power the computer on again the data stored from your old session is reloaded.

In the following article I am going to lead you through a systematic approach to diagnosing why Linux’s hibernation feature isn’t working on your computer and hopefully fix it. Here’s a Brief overview.

1. Not Enough Swap
2. Your Computer Isn’t Saving Your Session
3. You Computer Isn’t Reading your Saved Session on Boot
4. Your Computer Says “resuming from /dev/sdX” but freezes

1. Not Enough Swap

You should have as much swap as you have RAM plus some margin. If you try to hibernate and you are using more ram than you have swap the process will fail and sometimes hangs. Sometimes there is an error message that says “not enough swap” This is an easy problem to check for. Run the command in red.

chris@Starace ~ $ free -m
             total       used       free     shared    buffers     cached
Mem:         10005       9922         82          0       1647       5844
-/+ buffers/cache:       2430       7574
Swap:         8100          0       8100

The output shows the amount of swap and ram on my computer. As you can see I have 8005 Mb of RAM and I have 8100 Mb of swap. For a hibernate to work you have to have more swap than used RAM not counting cached), Also if you run out of RAM during your session your swap is used. To hibernate you must have free swap greater than the sum of your RAM and your used swap. As a general rule you should have a swap partition slightly bigger than your RAM (hopefully you aren’t using swap during your session, if you are it’s time for a RAM upgrade.)

If you don’t have enough swap or if you don’t have any swap, roll up your sleeves you need to repartition your hard drive.

Repartitioning to add more SWAP

Remember to be careful with your repartitioning, you can destroy your OS easily.

  1. Pull out your bootable CD/Jump Drive and boot It (we can’t repartition the drive we we are using it.)
  2. Run the “gparted” disk utility.
  3. If you have swap, right click -> Delete
  4. Right click on your linux partition -> Resize/Move
  5. Decrease the size of the partition by the amount of space you want to increase your swap. Click Okay
  6. Right click on the free space -> New
  7. Change the File System Type to “linux-swap,” click okay.
  8. Click the apply check mark in the top menu of gparted to apply the changes
  9. Right Click On the new swap partition -> Information
  10. Copy down the UUID value and /dev/sdXN value for later.
Linux Create Parition

Make Sure the File System is linux-swap

uuid info linux

Copy down the UUID and path values. We will use them later.

Note:Remember to be careful with your repartitioning, you can destroy your OS easily. After repartitioning you will need to edit your Linux Hard Drive file. Open up terminal and run the command.

chris@Starace ~ $ sudo gedit /media/NAME_OF_YOUR_COMPUTER/etc/fstab

If you had a swap partition before, look for the line that has the word swap and change the /dev/sdXN to the new /dev/sdXN value. You can also use the UUID instead of the path as shown in red. If never had a swap partition to begin with add the following line to the bottom of the “/media/NAME_OF_YOUR_COMPUTER/etc/fstab” file.


UUID=a453-Your-UUID-Number-ea33 none swap sw

The path variable can change depending on how you have your hard drive plugged in (ex /dev/sda1 -> /dev/sdb1). This usually isn’t a problem if you don’t move your hard drives around in your computer. However, Using a UUID is more reliable. The /dev/sdXN designator can change, but the UUID is unique to the storage device and doesn’t change even if you move to another computer.

After you’ve made the changes to the fstab file, shut down and boot your computer normally. To make sure this all worked run the following command in red. You should see your swap partition listed.

chris@Starace ~ $ cat /proc/swaps
Filename				Type		Size	Used	Priority
/dev/sdNX                         partition	8295420	0	-1

If you see this take you have successfully created/expanded your swap to accommodate hibernation.

2. Your Computer Isn’t Saving Your Session

If you’ve tried to get your computer to hibernate and it didn’t work it’s helpful to look at the hibernation log.

tail /var/log/pm-suspend.log

chris@Starace ~ $ tail  /var/log/pm-suspend.log
Running hook /usr/lib/pm-utils/sleep.d/00powersave thaw hibernate:

/usr/lib/pm-utils/sleep.d/00powersave thaw hibernate: success.
Running hook /usr/lib/pm-utils/sleep.d/00logging thaw hibernate:

/usr/lib/pm-utils/sleep.d/00logging thaw hibernate: success.
Running hook /usr/lib/pm-utils/sleep.d/000kernel-change thaw hibernate:

/usr/lib/pm-utils/sleep.d/000kernel-change thaw hibernate: success.
Sun Jul 24 13:15:14 HST 2011: Finished.

If you see something that has a date and says “Finished” like the what is shown in blue, that means that your computer successfully saved the session. If you see a bunch of errors then get ready to roll up your sleeves again. Unfortunately this is the hardest error to fix. There could be dozens of reasons for this to happen, but in my case it had something to do with binding and unbinding peripheral devices. The following article explains what I did to fix the problem.

http://chriseiffel.com/everything-linux/how-i-got-suspend-and-hibernate-working-in-linux-ubuntu-11-04-mint-11/

One solution that I found that worked for a lot of people, but not me is this simple fix

http://www.ubuntugeek.com/fix-for-suspend-and-hibernation-problem-for-laptops.html/comment-page-2#comment-53547

Don’t lose hope if you get stuck in this step. Instead google everything you can on the problem. Google the errors you see in the log. Someone has solved the problem you just need to find the solution.

3. You Computer Isn’t Reading your Saved Session on Boot

So your computer successfully saves a session, but doesn’t resume the session upon power up? It acts as if it was rebooted rather than hibernated? Well the good news is that this is a fairly easy thing to fix. This is most likely because GRUB the bootloader doesn’t know to resume from your swap. Take a look at the GRUB profile.

chis@Starace ~ $ sudo gedit /etc/default/grub

Look for the line that starts with.

GRUB_CMDLINE_LINUX

Add the following option in red.

GRUB_CMDLINE_LINUX=”resume=UUID=a353e-Your-SWAP-UUID-34eda other-option=value”

Or

GRUB_CMDLINE_LINUX=”resume=/dev/sdXN other-option=value”

You may or may nor have other options. Be careful that you type in the correct path or UUID for the drive here. If you don’t then when you try to resume you will have to boot in safe mode to fix the drive name and re-run the update-grub script. Save the file and then update grub with the following command.

chris@Starace ~ $ sudo update-grub

In addition to grub we need to update/create one more file. Edit the following file.

chris@Starace ~ $ sudo gedit /etc/initramfs-tools/conf.d/resume 

Add this line to the file.

resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7 

Then run this command to update.

chris@Starace ~ $ sudo update-initramfs -u

Now hibernate your computer and cross your fingers! It just might work.

4. Your Computer Says “resuming from /dev/sdX” but freezes

Linux is so close to hibernating and resuming successfully that it even says it is resuming. Fortunately this is another easy fix. The problem with this comes from two programs that are redundant. Removing them should fix the problem.

chris@Starace: sudo apt-get remove hibernate uswsusp

I know that the command may seem counterintuitive. but it worked for me so hopefully it will work for you.

All Done

Remember to check to make sure your USB ports work after the suspend/hibernate.

If you tried the steps above, please leave a comment below with your system setup (OS, Computer Hardware) so that we can create a reference that others can use.

Also I got a lot of my resources from the Ubuntu page on swap partitions. If you want to learn more about this subject read this article

https://help.ubuntu.com/community/SwapFaq

Happy Linuxing!

This entry was posted in ASUS G53SW Setup, Everything Penguin Related. Bookmark the permalink.

36 Responses to Step By Step How to get Hibernate Working for Linux (Ubuntu 11.04, Mint 11)

  1. zka says:

    The last step did not work for me, I had it to the point where the image was created onscreen: the percents progressed visually. then the same for restoring, hanging after 100% and a few more lines of text.

    after number 4, i can see my hard drive light running hard on hibernate, but no percents or anything on the screen. on resume, it never attemot to restore because of file system errors obvious the snapshot is broken now.

    • chb567 says:

      You could check to see whether your swap partition is still working!!! Check in GParted, and look whether the partition is still recognized as swap. I had this problem multiple times before I found this guide! I hope this helps.

  2. abarocio80 says:

    Thanks. Works perfectly (with some extra suggested tweaks) on a HP Pavilion dv4-2013la with Ubuntu 11.04v. How ever it required some reboots to work fine; I just don’t know why.

  3. Juan says:

    Gracias…luego de muchos días por fin pude solucionar los problemas.

  4. Pascal says:

    Hi! Just wanted to say thanks! I fixed my swap/hibernating issue on an old X300 using Lubuntu 11.x ! Merci!!

  5. Dimos says:

    Thanks it worked like a charm!

  6. Tim says:

    This worked wonders for me. I have an asus K53sv running kubuntu 12.x (precise) and I’ve been poking around this problem for a while. I had to install a custom ACPI hardware unbind script, which i would recommend anyway, as it is pretty generic.
    http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug

    But, I managed to get it halfway working with a few different methods, but the actual key for me was removing the confusion of extra packages with:
    “sudo apt-get remove hibernate uswsusp”

    Also FYI, in ubuntu 12, sleep/suspend functionality has been disabled by default because of all the trouble ACPI causes. You will need to re-enable (don’t have a link to hand)

  7. floatysarah says:

    I got stuck on the gedit stage. got response:
    sodu: gedit: command not found

    Have a friend who can probably help, just wanted to point out that there is no info for this result!
    thanks

  8. Aashish says:

    Thanks a TON!! :-) I had issue #4 and your fix worked like a charm.
    I had just upgraded my Ubuntu from 11.04 to 11.10 (yeah, I kn0w… its ancient by now) and hibernate stopped working, just like that.

    Thanks again,
    Aashish.

  9. Brandon says:

    Thanks man, this works perfectly to get hibernate working in 12.04 with an Asus u52f.

  10. rakesh says:

    HI,
    Does the solution given for case no:1 work with ubuntu 12.04 version ?
    my swap: 255Mb & RAM : 3557 Mb . I got the message saying “Not Enough Swap”.
    Thank you.

  11. rakesh says:

    I have windows and ubuntu both in my system. I have the case1 problem, i.e, ‘NOT ENOUGH SPACE’. Will this swap partition affect my windows ?
    Thank you.

  12. Florian says:

    This is the most comprehensive and well-explained article I could find on the topic, and Step 3 got my hibernation back! [Ubuntu 12.04 x64, Acer TravelMate 8372G]

    Thank you, chris!

  13. You are saying that `free -m’ shows that you have “8005 Mb of RAM”. Where does that number come from? Did you mean “_10005_ _MiB_ of RAM” as per “Mem: total 10005″? TIA.

    Regards,

    PointedEars

  14. Ricardo says:

    Good article, thanks! I would just suggest replacing the
    “resume=UUID=a353e-Your-SWAP-UUID-34eda other-option=value”
    with just
    “resume=UUID=Your-SWAP-UUID other-option=value”.
    I know you may have typed it like that to give an idea of the kind of value to fill in there, but it actually misled me on my first attempt.

    Thanks again!

  15. Sriram says:

    Great Tutorial!!!!
    I am very grateful for the google-hours you have saved me

    Cheers and thumbs up!
    :)

  16. James Beilby says:

    Great systematic approach, and worked for me on Ubuntu 12.04. Thanks!

  17. David V.T. says:

    Hi,

    The last step:

    sudo apt-get remove hibernate uswsusp

    Is the difference between your post and many others! All my configuration was perfect, but the hibernation just “off-on” the video in some seconds. I don’t remember when I instaleed those apps, but I didn’t suspet of a package problem as, by coincidence, I changed the swap partition some days ago.

    Thanks you!

  18. Anupam Das says:

    Excellent!! You made my day sir.

  19. Sriram says:

    Saved me some hours of googling!!!
    Thank you very much Chris :)

  20. Harshit Mittal says:

    Thanks chris, for such a wonderful post, it solved my problem of grub not reading my saved session on boot.
    you should update your lineresume=UUID=41e86209-3802-424b-9a9d-d7683142dab7 to mention YOUR-SWAP-UUID instead of hard-coding some value.

  21. Don says:

    Thanks for the very well-researched solutions. Unfortunately, they didn’t work for my system. I have a HP Envy dv6 notebook, dual booting Windows 8 and LinuxMint 14. The notebook completes all the suspend operations, but does not wake up. Could it be that the new Windows 8 boot loader is interfering?

  22. Joe Zyzyx says:

    Why do you say the UUID doesn’t change? When you move or change the partition it does change. The LABEL if one is give remains however. In fact the loss of proper hibernation is often related to having the UUID change due to some adjustment of the swap partition. If the swap was setup as a file instead of in a separate partition, then having hibernate process lose it, will not happen.

  23. Jogi says:

    Oh MAN you save my day!

    sudo apt-get remove hibernate uswsusp

    did the trick for me.. a fully working hibernate now.. :o) Thanks!

  24. Jogi says:

    Oh MAN you save my day!

    $> sudo apt-get remove hibernate uswsusp

    did the trick for me.. a fully working hibernate now.. :o) Thanks!

    EDIT: Ubuntu 12.04.2 LTS 64 bit edition running on a laptop

  25. Shawn Flynn says:

    Howdy Chris,
    Regarding step-by-step how to get hibernate working:
    Very well done step-by-step. But I’ am weary/scared!
    I am a complete newbie…I am running Linux Mint 14. And cannot resume.
    I have 300gb ext4 and a 30gb swap. And a completely fresh install of Mint 14.
    ran this:
    cat /etc/default/grub |grep GRUB_CMDLINE
    GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
    GRUB_CMDLINE_LINUX=”"
    Ran:
    cat /etc/initramfs-tools/conf.d/resume
    RESUME=UUID=314b5dba-03ae-4e37-94b7-1067553ccbfc

    I am scared to death to edit the grub line: GRUB_CMDLINE_LINUX=”ShawnNeedsToAddSomethingHere”
    As I just don’t understand what I suppose to add.
    “resume=UUID=a353e-Your-SWAP-UUID-34eda other-option=value”
    It appears to me I should add /edit this portion
    resume=UUID=a353e-MY-SWAP-UUID-34eda other-option=value
    But I don’t what my swap UUID is ? Or exactly what
    GRUB_CMDLINE_LINUX=”resume=/dev/sdXN other-option=value” is?

    Sorry to bug you. But I love’n this Linux Mint 14. But I have already totaled by box by editing the grub. Spent a day ‘re imaging’ my dual boot…can’t completely break from win, yet.
    So my only complaint is that I can’t get Linux Mint 14 to sleep or hibernate….

    -Shawn

  26. Shawn Flynn says:

    Hey Chris,
    Got it, I think…
    shawn@MintOffice ~ $ sudo blkid
    /dev/sda1: LABEL=”System Reserved” UUID=”9818E3EE18E3C978″ TYPE=”ntfs”
    /dev/sda2: UUID=”324CED694CED27F5″ TYPE=”ntfs”
    /dev/sda4: UUID=”089f4092-383e-4fe2-8efc-a51d7059168b” TYPE=”ext4″
    /dev/sda5: UUID=”314b5dba-03ae-4e37-94b7-1067553ccbfc” TYPE=”swap”
    /dev/sdb1: LABEL=”System Reserved” UUID=”2C74722E7471FB42″ TYPE=”ntfs”
    /dev/sdb2: UUID=”187C7B7D7C7B550A” TYPE=”ntfs”

    sudo gedit /etc/default/grub
    edited the line. With the above UUID.
    sudo update-grub
    and checked it:
    shawn@MintOffice ~ $ cat /etc/initramfs-tools/conf.d/resume
    RESUME=UUID=314b5dba-03ae-4e37-94b7-1067553ccbfc
    shawn@MintOffice ~ $
    Maybe this will get’er done!
    -Shawn.

  27. Łukasz Cholewa says:

    YES!!!
    After counless hours, step 4 was the right one! Thanks! I will praise your fame on other forums.

  28. Spam Hater says:

    Thank you for this post. As many other folk commenting here, this saved my bacon. Worked out the issues with hibernate/resume for me on Linux Mint Debian Edition. Hibernate now works flawlessly as it should. I can confirm that the last point (uninstalling extraneous related packages) was also an issue in my case as well and was the final piece of the puzzle for me.

  29. Jeff says:

    Incredibly helpful! Step 3 solved it for me. Turned out that my GRUB_CMDLINE_LINUX value disappeared after I changed swap partition size on Mint 15.

  30. chb567 says:

    Worked perfectly! Thanks for the guide!!! This is the “only” complete guide I found, the other guides leave out the “resume=UUID”-thing in the grub file!

  31. Julian says:

    Thanks for this _very_ good guide covering many problems at once. Suspend/resume used to work for me in Ubuntu 13.04 but failed after moving to Linux Mint Debian Edition 201403, which I found strange. Turned out to be issue #3 – the GRUB part.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>