Enable hibernation in Ubuntu 14.04 (and others)

The other day I was doing a job for the University. When I decide to turn off the computer and go to sleep it occurs to me that it is better to put it on hibernate, so I don't have to open all my programs in the morning. What a surprise, that the hibernate option in Ubuntu does not appear in the session menu in Unity, so I had to hibernate from terminal.

Days later I realized that the same thing happens on my computers with Xubuntu y KubuntuSo I started looking for a solution.

The why of the problem

It was decided that it was better to disable the hibernate option in Ubuntu by default since there are many computers in which it does not work correctly, which can cause data loss.

Check if your equipment is compatible

A very simple test can be done from the terminal. Here an excellent post from Kzkg ^ Gaara.

My computer is compatible, how can I enable hibernation in Ubuntu?

It is very simple, you only have to edit one file.

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

and add the following

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

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

What it does is add a policykit rule (used to control system privileges) to allow us to hibernate.

At the next restart the option should appear in the menu:

hibernate in ubuntu

Fonts

Ask Ubuntu | Official Documentation


19 comments, leave yours

Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Domingo Gomez said

    Perfect. I just implemented it and it works. Thank you.

  2.   JLX said

    what I would like is to be able to configure to hibernate when pressing the power button, in kde if it is possible easily, but in Unity-Gnome I still don't know how to do it

  3.   Julius linarez said

    There is a way to do it but cn elementary OS ???

    1.    dacooks said

      It is the same procedure 😉

  4.   Martin said

    Thank you!

  5.   jose said

    If it worked for me ... I think, because it showed me a message, apparently an error. I don't know if it happened to someone else.

  6.   year said

    I have ubuntu 14.04 lts x64 I did everything, but it still does not work and when chekee gave me that if it accepts hibernation
    with win7 I can do it.
    I do not get the option and that I restart and everything
    Is there a command missing to update the file? or save it?

    1.    Lelo said

      I also modified the file and saved it but everything remains exactly the same, as if I had not written anything. 🙁

  7.   EstebanZ said

    Thank you very much, it is my first experience in Linux and now I see all the help there is! Especially in Spanish! 😀

  8.   djcg said

    Thanks if it works great for me I even activate the hybrid sleep function

  9.   Pablo said

    Thanks for the info!!

    I have some doubts.

    A long time ago, when I decided to add ubuntu to my netbook, I asked for help and they recommended creating a partition like this: "A logic, swap system, 1 gigabyte commonly used, triple the ram to hibernate / suspend"

    My question: Does it automatically suspend there, or do you have to configure something?

    Another question, when hibernating, it saves the session to disk .. On which partition?

    Thank you!

    1.    Ezekiel said

      When you create that partition for sleep / hibernation, you give it a special name, the operating system recognizes the partition with that name for that use.

  10.   mouse45 said

    Great, it works 100% on Xubuntu, thanks

  11.   Omar said

    Incredible, it worked for me! many thanks!

  12.   Matias said

    Hi, I am new to all this Linux and I started with ubuntu, I wanted to add the hibernate function, all Ok the hibernate button appeared but when pressing it the laptop freezes and does not go into hibernate mode, I did all the steps as shown here , I read comments on this post and the one you refer to to find out if the machine allows hibernation (check and I get freeze mem disk) but I have not found a solution, try with the sudo pm-hibernate commands but with the commands it does nothing.
    Does anyone know what can I do?
    Help ...

    1.    Samuel said

      Check that you have a SWAP partition equal to or greater than the RAM installed on the computer.
      Otherwise, trying to dump the contents of RAM will fail.

      All the best

    2.    Anonymous said

      Install Windows.

  13.   John Anguiano said

    Excellent!
    Thank you very much for your help, have a happy 2016

  14.   kaseca said

    Thank you very much it helped me a lot, and it works perfect ... I thought I had to increase the size of the swap but for now it works fine ... I have 4 gb of ram and 2 of swap ... is it okay or will I have to increase the swap?