Enable Hibernation on Ubuntu

One of those note-to-self posts!

Why does Ubuntu come with Hibernation disabled by default?

Ubuntu had to resort to such measures as users experienced a lot of issues like:

  • No resume after suspending the PC — in a limbo
  • Open files and folders gone — Shutdown instead of hibernation
  • Wifi etc devices not working after waking up — the worst nightmare

And that happened because there wasn’t enough Hardware support. Even in Ubuntu derivatives like Linux Mint it came disabled.

What is hibernation?

Seriously? Forget it. I am not even going to look at you.

Alright Alright suit yourself: https://help.ubuntu.com/community/PowerManagement/Hibernate

Advantages of Hibernation:

  • You have an edge over “suspending”. It saves power.
  • The exact state of the computer is resumed.
  • Major use case for the people who leave their  PCs unattended (think: http://Torrentz.in)

How to enable it in Ubuntu:

Step#1 Check if hibernate works on your hardware.

  • Open Terminal (CTRL + ALT + T)
  • Save your work first and then type
 $ sudo pm-hibernate 
  • If everything goes smoothly, start your laptop and continue iff things look good.
  • If you see anything unexpected then please make sure that the size of SWAP is at least as large as the RAM or just 
     System.exit(1) 

Step#2 You can continue to use that command safely or make it permanent by enabling it on the menu (do it only if Step#1 above works)

Open terminal and type:

 $ sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla 

Enter the password

(instead of `gedit` you can use `vi` its awesome)

hit “i”; paste; hit “ESC”; hit “:”; hit “x”

Step#3 Paste the following lines in the blank file you created just now.

[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

Hit Save and Quit.

Step#4 Reboot for the changes to take effect.

If upon restart you still cannot see the “Hibernate” item in the menu, then you need to Tweak the Grub but mostly it would not come to that.

And we’re back …

Also check http://nikunjlahoti.com/2012/04/29/ubuntu-12-04-fix-fn-brightness-keys/

Sources:

https://help.ubuntu.com/12.04/ubuntu-help/power-hibernate.html

https://help.ubuntu.com/12.04/ubuntu-help/power-suspendfail.html

34 thoughts on “Enable Hibernation on Ubuntu

  1. Hi!

    I enable hibernation and it worked fine but now I want to revert back.
    How do I remove the hibernate button in the menu?

    Thx, Seb

    • Wow that’s unorthodox. 🙂 I will find out + verify and let you know.

      Ideally it should be as simple as removing the text file that you created “above” while enabling it.

      Also, I believe there isn’t any harm in letting it be! Are you facing any issues with the Hibernation?

      • Hi,

        Don’t bother! For info I thought it took a long time for the system to start up from hiberation, that’s why I wanted to remove it. Tried some stuff only to be stuck with a system error after each reboot so I re-installed ubuntu. I’m a newbie with Linux so that taught me a lesson!

        Seb

      • Nice. Well re-installation is good because of two reasons.
        #1 You are not removing and saying goodbye to Linux for good.
        #2 You get to customize the system differently and have a clean slate.

        To be on the safer side (which you do not have to be), you must install VirtualBox and try installing + using a wide variety of *NIX derivatives (flavors)! Think: Solaris. Think: FreeBSD. Think: Debian. Think: Slackware 🙂

        Happy Hacking!

  2. When I tried “sudo pm-hibernate” it did but came back by itself, everything on its place, is it expected to hibernate until I wake it up?
    Regards

  3. Hibernate isn’t actually completely hidden by default – it does appear in the shutdown menu:

    I don’t know how to actually open that menu (the command?) – on laptops the physical power button should open it.

    • Ok … ?

      Yes pressing the power button would throw such a menu. Do you see it? It doesn’t show Hibernate for me. Does it work for you (what happens when you press it?)?

      I think different Desktop Environments expose different capabilities. My XFCE on Linux Mint shows everything.

      • Whoops, my fail. 😀 It was your trick that added the option to the shutdown menu too… I just forgot I did the trick in the first place (and coincidentally only then found out the power button shutdown menu). So: also hidden by default, your tricks adds it there too. Hibernate works for me whatever the way.

        I use default 12.10 Unity (I’m about ‘this’ close to going back to MATE though…).

  4. So after I used the terminal to pm-hibernate, once the screen went black i got an error message about some acpi device returning -6 and “failing to thaw” but other than that my computer seems to have hibernated and returned without any further problems. Is it still a good idea to activate the hibernate feature? (ubuntu noob here)

    • Well that depends on you. If you think Hibernate is really adding any value then its definitely worth a try.
      You must make sure that everything is just the way you wanted (I mean before, after and during the hibernation)!
      I mean to say if a Driver doesn’t know how to do that then when it gets back online (lets say your WIFI driver), you wouldn’t be able to browse Internet. So check if all your driver are up-to-dated (or wait-for-it). 🙂 Happy Exploring!

    • If everything seems to work ok, yes. I’d ignore the errer messages until problems occur in which case the error might provide a lead…

  5. Yayyyyy… I could do it…I could do it!! 🙂 🙂 Simply Awesome \m/
    Alright as this is your ‘Technical Blog’ I think I should be less informal :-/ #Phooey 😀
    Amid the long list of Thank you’s that are already posted for you…I would like to add
    I AM SIMPLY LOVING THE EXPERIENCE… #RaringRingtail
    🙂
    ALL Thanks to you Mr Digerati.
    Keep Rocking!!

    • Simply awesome!! That’s for you. I mean given the speed with which you are reading RUTE – you are soon going to have a Technical Blog of your own 😀 Yeah! Phooey to the `less informal`!! #HappyHacking #Ubuntu

      Now tell me… have you ever hibernated your PC after that?? 😀 I mean I do not. Don’t know why!

  6. Haha 😀 😀 I didn’t … I didn’t!! I am not sure why.. but I remember giving you something as an answer 😀 😀

    And after vainly trying to understand all your Technical blog-posts… 😐
    I could finally implement One…no wait…TWO Yaaayyy Yaaayy!! 🙂 🙂 #FeelsGood

    My Technical blog…Yo… That tickled my fancy!! 🙂 😉

    Learning RUTE is definitely FUN 🙂 Thank YOU!!

  7. WHEN I RUN THE COMMAND SUDO PM-HIBERNATE THE SCREEN GOES BLACk for a second and displays :
    cannot find swap device, use swapon -a
    and the sreen again comes back . any suggestions???

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s