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.
- Pull out your bootable CD/Jump Drive and boot It (we can’t repartition the drive we we are using it.)
- Run the “gparted” disk utility.
- If you have swap, right click -> Delete
- Right click on your linux partition -> Resize/Move
- Decrease the size of the partition by the amount of space you want to increase your swap. Click Okay
- Right click on the free space -> New
- Change the File System Type to “linux-swap,” click okay.
- Click the apply check mark in the top menu of gparted to apply the changes
- Right Click On the new swap partition -> Information
- Copy down the UUID value and /dev/sdXN value for 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.
One solution that I found that worked for a lot of people, but not me is this simple fix
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!
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.
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.
Turns out I had this issue (your number 4):http://forums.linuxmint.com/viewtopic.php?f=47&t=74010
on top of this one:(number 3):http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528483
Multiple bugs, painful. Glad to know I could help you squish them.
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.
Gracias…luego de muchos días por fin pude solucionar los problemas.
Hi! Just wanted to say thanks! I fixed my swap/hibernating issue on an old X300 using Lubuntu 11.x ! Merci!!
Thanks it worked like a charm!
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)
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
try “sudo” instead of “sodu” 🙂
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.
Thanks man, this works perfectly to get hibernate working in 12.04 with an Asus u52f.
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.
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.
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!
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
The total section should be the sum of all memory/ram that your computer posesses.
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!
Great Tutorial!!!!
I am very grateful for the google-hours you have saved me
Cheers and thumbs up!
🙂
Great systematic approach, and worked for me on Ubuntu 12.04. Thanks!
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!
Excellent!! You made my day sir.
Saved me some hours of googling!!!
Thank you very much Chris 🙂
Thanks chris, for such a wonderful post, it solved my problem of grub not reading my saved session on boot.
you should update your line
resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7
to mention YOUR-SWAP-UUID instead of hard-coding some value.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?
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.
Oh MAN you save my day!
sudo apt-get remove hibernate uswsusp
did the trick for me.. a fully working hibernate now.. :o) Thanks!
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
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
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.
YES!!!
After counless hours, step 4 was the right one! Thanks! I will praise your fame on other forums.
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.
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.
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!
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.
I have Linux Mint 17 (Cinnamon) and my problem isn’t any of the above. When I ask the laptop to hibernate, the screen shuts off, but the laptop is still running (you can hear the fan). I have to turn it off using the power button, and then turn it back on when I want to resume my setting. I thought hibernate was supposed to turn the power off by itself. Any ideas of how to fix? Thanks in advance.
Hi Chris,
first of all, thank you! This the best overwiew I found in the last five hours!
I am using Kubuntu 12.04 lts on a Toshiba Satellite A100-775 notebook. As I found out here https://lists.ubuntu.com/archives/kubuntu-users/2013-April/057823.html the problem “Hibernate missing in Kubuntu 12.04 lts” is known. In my case, the german “Hibernate”-button simply locked the screen. And the solution was using the command pm-hibernate instead of the menu. (Maybe you want to add this problem to your list?)
BUT: By the time I got there I had tried out several scripts and packeges and I needed your point 4 to get everything going. THANKS!
Sarah
THIS WORKED!!!
THANK YOU!!!
(been trying to get this working since I installed Zorin a few months back)
I’m using this site as reference!
all I had to do was:
$ sudo apt-get remove hibernate uswsusp
Linux Mint 17.1 Rebecca
Mother Asus, AMD processor
Option 3 was my problem.
In addition, another thing to have in mind is that if you have multiple swap partitions the one that worked for me was in the same disk as the OS. I don’t know if this is something obvious or not. In case one of them doesn’t work, keep trying the others.
Thanks for this post, it was really helpful. 🙂
Regards
Worked perfectly for me 🙂
System: Kernel: 3.13.0-37-generic x86_64 (64 bit gcc: 4.8.2)
Desktop: MATE 1.8.1 (Gtk 3.10.8~8+qiana)
Distro: Linux Mint 17.1 Rebecca
it works perfectly in Linux moto 3.18.0-kali3-686-pae #1 SMP Debian 3.18.6-1~kali2 (2015-03-02) i686 GNU/Linux. core2duo E7500 with MSI 775 board.
blkid >> to get UUID of swap
leafpad /ect/fstab >> change UUID of swap and save
leafpad /etc/initramfs-tools/conf.d/resume >> change UUID of swap and save.
leafpad /etc/default/grub
GRUB_CMDLINE_LINUX=”resume=UUID=a353e-Your-SWAP-UUID-34eda”
and save.
update-initramfs -u
update-grub
Then hibernation was successful.
Pingback: Ubuntu:Why does hibernate not work after update from 13.10 to 14.04? – Ubuntu Linux Questions
Thanks for these instructions!
Just a suggestion to make things clearer: the GRUB_CMDLINE_LINUX commands contain fancy quotation marks which, when copied directly into the grub file, break things. They might be the automatically inserted by the blogging software?
Mine wasn’t resuming… Now it is. Thanks!!!!!!
It works for me to resume from hibernate after I finish this line.
GRUB_CMDLINE_LINUX=”resume=UUID=a353e-Your-SWAP-UUID-34eda other-option=value”
Model:Thinkpad x230t
distribution: ubuntu 14.04
kernel number: 3.13.0-79-generic
Thank you a lot.
Debian Linux jessie desktop:GNOME on toshiba core i7, 4gb ram,
Hibernate was not working. it resolved itself when my user id was added to sudo group.
Regards,
Thank you for this guide. It worked for me on two (relatively recent) Linux Mint installations. They had slightly different deficiencies, but both worked. Reckon I’ll see if it will work on a CentOS installation also.
Thanks Chris. Your blood’s worth bottling (as the expression used to be).
Note that your kernel may not be able to use UUID on boot. In which case, you will need to use “resume=PARTUUID=YOUR_SWAP_PARTITION_UUID” or resume=/dev/sdXN
Your PARTUUID can be obtained with the blkid cmd as well.
Hello. I tried the methods above and the hibernation finally works. Thank you very much.
Anyway, though the hibernation seems working, but there is no “finished” line when I use tail /var/log/pm-suspend.log after the successful hibernation. And other lines are ending with “hibernation success”. Is this normal?
Also, when I try to suspend my laptop, It does suspend but I heard a kind of a very small “peeeeep” noise coming from my laptop. Also, is this normal?