Question About Hibernation

Asked by Gregory Lew on 2011-07-27

Hello,
         Whenever I try to Hibernate my machine it does appear to do so, but then after I turn it back on it just goes like if it were booting up. Next thing I know I'm at the login screen of Ubuntu 11.04 (not lock screen), thus resulting in loss of precious data. This "hibernation" would work like the one on Windows right? (start>shut down computer>> Hibernate, then it saves data to disk and shuts down. When turned back on you get to the lock screen and your data is intact.) Would there be any workarounds to disable hibernation or any fixes that would make hibernation work?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu hibernate Edit question
Assignee:
No assignee Edit question
Solved by:
Gregory Lew
Solved:
2011-07-31
Last query:
2011-07-31
Last reply:
2011-07-27
Gregory Lew (gregorylew-h) said : #1

By the Way thank you very much!!!!

Chris (fabricator4) said : #2

Hi, how much RAM do you have in the machine, and how big is your swap partition? Ubuntu cannot hibernate to a swap file on an active partition. If you're going to use hibernate the swap file needs to be at least as large as your RAM, or at least that is the usual recommendation.

Have a look at the Swap FAQ: https://help.ubuntu.com/community/SwapFaq especially the parts about hibernation and how to increase your swap partition size if this is the problem.

You can get information on memory size and swap size by opening a terminal and typing:

free

Post the output here if you are not sure.

Chris

There are a few things you first need to check for hibernate to work. First of all, when you hibernate your system, an image/snapshot is saved in your swap partition that Ubuntu uses to wake up your system and restore the session you hibernated from. This requires your swap partition to be of equal or greater size than your current RAM installed in the system. For instance, I have 1 gigabytes of memory in my ubuntu system, and my swap partition size is around 1024 megabytes (equals to 1 gigabytes).

So if your swap partition is too little to hold a hibernate image, then the cause may be that ubuntu simply reboots instead of saving an image. So first check and correct that problem.

Btw. to create a swap partition and making it active) I usually use GParted, and MountManager to create and then save the proper configuration to the fstab configuration file. Mind you that if you use "swap on" in GParted after creating a swap partition, it only stays ON until you reboot, that is why you need MountManager to save your settings to fstab (where you system holds information about mounting devices - incl. mounting your swap partition).

The reason why your system reboots normally instead of waking up from hibernate, is most likely that the configuration file "/etc/initramfs-tools/conf.d/resume" is missing the proper path to your swap partition.

To modify (or create) the proper resume entry and updating your system to reflect the changes, do the following.

Go into a terminal and switch on root access, by typing: "sudo -s" and entering your password. Then CD to the directory "/conf.d" mentioned above, and check if the file "resume" is missing. If it's missing, create and save a new file (plain text) using the command "gedit resume" to edit or create the file.

The file "resume" must contain the text "RESUME=UUID=" + the actual UUID for your swap partition (locate it by viewing information on your swap partition using GParted). For instance my own configuration file lists (an example): "RESUME=UUID=79647610-c76d-4220-8c58-b4b9c71f9ead". Yours should reflect the UUID that your own swap partition has.

Then save the "resume" file and check if it reflects the proper information, and use this command to update the system so that your changes is reflected: "update-initramfs -u", alternatively "sudo update-initramfs -u" (the -u stands for update).

After this has been done, your system knowns the proper location to your swap partition and thus the proper location to wake up your system from hibernate properly.

Now mind you that if (like me) are using a NVidia GForce graphics card and the proprietary drivers, then these drivers will probably interfere with hibernate waking up properly. So you need to use either the regular drivers (without 3D-acceleration) or the third option (which I recommend and use) the experimental drivers for NVIDIA that supports 3D-acceleration (in my experience they may be experimental, but they so far work flawlessly, at least on my system).

Now I have tested this on both my desktop and notebook system with Ubuntu 11.04 Natty installed, and now hibernate works perfectly in both places.

Another customization that I have done, though it is not necessary, is to make the swap partition a primary partition using GParted. I dislike extended partitions, because it looks more messy in GParted, but I guess that is optional. By default Ubuntu creates an extended partition for the swap file.

Well, now your system should save the hibernate file, and be able to reboot and wake up hibernate properly.

Oh, and a little qwirk I forgot to mention. After your systems reboots hibernate properly, you will probably get a blank (dark) screen, until you move your mouse, and then the login/password dialog appears. (Atleast that is how it is on my own two ubuntu systems).

As a note to note#3, when I said "login/password dialog appears" I meant actually the "lockscreen" where you enter your password, and then you are back in the pre-hibernation session. :)

Gregory Lew (gregorylew-h) said : #6

@ Stefano one problem though I go through gparted to see my UUID of the swap partition but it says the partition cant be recognized. Is that why Mount Manager is used? It's because I can't find that ID of the partition and I tried uninstalling the driver (Nvidia) but still It won't Hibernate properly.

Gregory Lew (gregorylew-h) said : #7

I tried Going with your instructions but GParted does not recognize the swap partition's file system. I don't know what to do now.

If GParted does not recognize your swap partition properly, try deleting the partition and recreating it (with GParted). After that, use "Swap on" in GParted on the partition to activate swapping on it, and then go into Mount Manager and use "Apply" from the first menu; partition menu. You can always check if the system uses your swap file, by going into the system monitoring tool (dont know what its called in english, since I use danish localizations), but remember Mount Manager / apply is needed after activating swapping, to make the settings stay after reboot, look below.

Mount Manager is to update the fstab (mount configuration file) so that it reflects the current changes, more specifically for the system to keep a swap partition as "swap on" even after a reboot. Usually if you only set Swap on on the swap partition using Gparter, it forgets the option after reboot - that is where Mount Manager comes into the picture.

Regarding the GFX-card, use the experimental 3D driver, the third option in the additional drivers, where you activate/deactive your graphics drivers. But this is only for being able to see the lockscreen once hibarnation reawakening is complete.

- Stefano

I have made a complete reinstall to find the best procedure and refine the above a little further, and try to reproduce your problem.

First of all, the swap partition is okay as an extended partition, it seems the system and initramfs-tools likes it a little better than a normal partition. So let your swap partition be extended afterall.

I also got a corrupted swap partition shortly after installing ubuntu and I think it has to do with hibernating when /etc/initramfs-tools/gconf.d/resume is missing, which I found it was already after reinstalling ubuntu 11 from scratch. The solution to this is to use gparted and delete the corrupted swap partition and the extended partition, recreating the extended partition and the swapfile, turning it on (swap on) in gparted, and reflecting the changes with apply in mount manager. Gparted may need you to reboot after deleting the swap partition the first time, due to it being active in the system. But after a reboot you will be able to recreate the extended partition and formatting as swap file, and the same procedure again.

Now, when you edit the 'resume' file mentioned above, you shouldnẗ need to do 'sudo -s' to enter root mode, instead when in the gconf.d folder, simply do "sudo gedit resume", edit the resume file to point to the swap partitions, eg. "RESUME=UUID=" + the actual UUID for your swap partition, as mentioned in a comment above (with example), then save the resume file, also mentioned before, and then doing "sudo update-initramfs -u".

Now change your nvidia gfx driver to the free experimental nvidia driver (one of the three nvidia driveroption in the system).

Then make a reboot, and then hibernate (you may not need to reboot there, but better being on the safe side that all info is updated correctly)... When you then reboot after hibernate and after a while move your mouse to get the hidden lock screen, you can enter your machine exactly as it was before hibernate.

This is the 3rd time I've reproduced the fix on my machines, so I positive it will work for you aswell, if you manage to follow the instructions, that may be a little complicated, I donẗ know, but ask away if there is anything.

- Stefano

Oh, I mentioned the word "swapfile" a few times above, - ofcourse I mean swap partition, only. Swapfiles is better left to windows, although Ubuntu can use one ;)

cheers...

Gregory Lew (gregorylew-h) said : #11

Yeah I did that too. I reinstalled Ubuntu but instead of the 3 gb swap partition I made a 10 gb partition. The reason for that was that when I have used Ubuntu 10.04 It made the swap partition as a 10 gig. I took a look in Gparted and Gparted recognized it. So I don't know either Gparted is a little old in the repos or what. I'll try your solution, Hopefully by the next release they will fix this issue.

Gregory Lew (gregorylew-h) said : #12

GParted recognized it in 10.04.

Gregory Lew (gregorylew-h) said : #13

Ok so I tried doing what you told me and It worked but now I get a blank screen. I think this is a big issue with the installer because in 10.04 Hibernate was working fine. It's very annoying.

have you tried moving your mouse when you have the blank screen? then the lockscreen should pop up, since it's simply hidden, eg. ubuntu return from hibernate into a locked state. If that doesn't work, then maybe check if you are using the experimental nvidia driver, not one of the two ordinary nvidia drivers listed in the 3rd party drivers in the administration menu (at the bottom on my system with danish localization).

Here it works every time, both with a S9e Ideapad system (notebook) with internal gfx card (intel) and an amd 1,7 athlon xp system (desktop) with nvidia gforce 6200 gfx card, but required the experimental free nividia 3d driver instead of nvidias own 3d drivers.

But try moving your mouse on the blank screen, changes may be you get the lockscreen on.

If that doesn't work, and you've followed my instructions precisely, and you have the experimenal 3d nvidia driver alternative, then I am at a loss what is wrong, but chances would then be, that you have missed out on something or I have explained some of it poorly, or some yet third kind of problem.

- Stefano

Gregory Lew (gregorylew-h) said : #16

Thank you Stefano! I am still Going to keep trying. I already Filed a bug saying that after installation the swap partition is corrupted. I tried moving the mouse but it does not respond so I don't know what is going on. Hopefully by the next release they fix this because if not then the chance of losing data is much higher when putting the system on hibernate.

You're welcome, but let's not give up yet. May I ask what gfx card you have, and your system specs? - and try to tell me the exact procedure you did when trying to fix it, because it may be just a little thing that we did differently. And when you install the gfx card driver, what driver do you install, and how? If you can provide as much info as possible, I may be able to figure out (if it something that can be fixed, atm) what went wrong, or what you should do.

I will try to summon up very systematically.

1) Delete / recreate corrupted swap partition using GParted, and turn swap partition "swap on" (also in GParted). Check that Swap Partition looks okay (eg. not "unrecognized")

2) run mountmanager and use "apply" (in MountManager) to update system FStab, so ubuntu can find swap partition after reboot.

3) gather the UUID number of the swap partitition (copy/paste or write it down) by using INFO on swap partition in GParted.

4) go into a terminal, and "cd .." + "cd .." to go to root, then "cd etc", "cd initramfs-tools", "cd conf.d" (with enter after each command typed) and check with "dir" if there is a file called "resume" (if not, we need to create it, else to edit it).

5) type "sudo gedit resume" (after which Gedit opens up a text editor window where we can edit and save the "resume" file)

6) edit in the text window so that it says: "RESUME=UUID=90189907-9d09-435d-8229-e10448015c37" where you substitude everything after RESUME=UUID= with the numbers that make up your swap partitions UUID, that you recorded in 3). Now, save the window (so that resume file is created with this data)... remember not to write the ""-brackets in the resume file, only the clean text eg: RESUME=UUID... etc. etc.

7) type "sudo update-initramfs -u" (which updates ubuntu, to know where to hibernate precisely)

Now you should be able to hibernate and after you turn on machine again, it loads for a while and you get a dark blank screen (like a lockscreen) where you can move mouse and voila type password and get out of hibernate (if you use a passworded system, if not you get probably directly out of hibernate).

- If you have followed these instructions exactly, then it should work, atleast it worked on every install I made on two different type systems I have, both running Ubuntu 11.04 Desktop edition.

- Stefano

- Stefano

Gregory Lew (gregorylew-h) said : #18

I Fixed it. I recreated the swap partition (both the extended partition and the swap partition), Updated Fstab so it can find the swap partition after the reboot, got the UUID number of the partition, went into the terminal and edited the resume file, ran "sudo update-initramfs-u". But there was one more thing. Update Grub bootloader so it can reference to the swap partition if you hibernate. It was under the documentation link the first guy posted. It goes through the steps like you did (except no need for mount manager, just gparted). I have followed your instructions, and they are good (of course you seem like a ubuntu expert, you know the commands :) ) So thank you Stefano! (By the way I am a newbie at Linux). I just hope they fix this issue when the next version of Ubuntu comes out.

Gregory Lew (gregorylew-h) said : #19

My Gfx card is an Galaxy Geforce GT 240 (Nvidia). What I did was this:

-I deleted the corrupted Swap partition (and the extended one also) via Gparted
-Rebooted Ubuntu 11.04
-Re-created the extended partition and swap partition via Gparted
-then I found the UUID of the Swap partition in Gparted (like you said)
-Ran gksu gedit /etc/fstab & and looked for the line that has *swap* in it.
-Pasted in the UUID of the swap partition (also changed the physical path to /dev/sda5) the path was also shown in Gparted. Then I saved the file and rebooted.
-Next I pulled up a terminal and ran "cat /proc/swaps".
-"gksu gedit /etc/default/grub" (to pull up boot configuration data)
-LookED for the line GRUB_CMDLINE_LINUX="(UUID GOES HERE)"
-Pasted in the UUID
-Saved it, then ran "sudo update-grub"
-gksu gedit /etc/initramfs-tools/conf.d/resume (same as what you did with resume=UUID=(UUID Number of Swap)
-saved it and ran "sudo update-initramfs -u"
-Then I rebooted.

I have tried your instructions and it seems to work now but instead of using mount manager I edited the fstab Config file manually so thanks very much for helping me.

Glad to hear it works for you now, and thanks for the steps to do the fstab/grub updating via the terminal. You seem much of an expert yourself. :-)

- Stefano