53

I know that since 12.04, we need to add a policykit rule to enable hibernation (see question How to enable hibernation? and the Official Documentation).

I can successfully bring my laptop into hibernation mode with sudo pm-hibernate or sudo s2disk, so the rule is in place and works, but the hibernation entry is still missing in the menu.

I can tell from looking through the source of the indicator-session package (but not understanding the whole code) that there is still a hibernation menu entry in the code and it should be displayed when the system is capable of hibernating. Please calm down if you're enraged by this. This is very unlikely to be a conspiracy, but rather a bug/regression on a deeper level, which can happen when you move code around or replace it.

Question: What needs to be done in 13.10 to properly tell indicator-session that the system can hibernate?


Possible duplicate: Hibernation still not available - No activity, because saucy was in development at that time, so out of scope for AskUbuntu.

Related bug report: https://bugs.launchpad.net/ubuntu/+source/indicator-session/+bug/1232814

LiveWireBT
  • 28,763

4 Answers4

62

14.04 and beyond

Mitch points out in his answer for 14.04 and 16.04 that you should check 10-vendor.d/com.ubuntu.desktop.pkla before modifying anything. Also check that you have Secure Boot disabled and if that brings the menu option back.

Re-enabling the hibernation option in the menu

To re-enable the hibernation option in the menu, your /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla should be modified to look like the following in saucy (13.10):

[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

Then reboot or run killall indicator-session-service in your session and you should have your hibernate functionality/menu option back. Create the file if it doesn't exist already.

Investigation from bug report

Citation from Jeffery To's post on Launchpad Bug Report #1232814:

For Saucy, indicator-session was updated to use logind (org.freedesktop.login1) instead of upower.

If you check /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla, you'll see that hibernate is disabled by default in both upower and logind.

So the first step to re-enable the Hibernate option is to edit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla to something like:

[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

After rebooting, the login screen session menu should have a Hibernate option.

[...]

All thanks and credit go to Jeffery!

Why was hibernation disabled?

There exists a bug report on launchpad that suggests disabling suspend/hibernate instead of tracking which hardware "certifies" for which power modes. It's claimed to be a more scalable approach.

Another thing to mention is that using UEFI Secure Boot and hibernation appears to be possible but may be a risk to circumvent the former. (1, 2) As a reminder, when you use hibernation you store everything in RAM to disk without encryption, this includes passwords for encrypted filesystems and containers.

At some point with 16.04 I had to disable Secure Boot to be able to hibernate my laptops. In my case I used uswsusp and testing with s2disk returned the message below. This may give you a hint that your issue, why you can't hibernate although everything else is in place, is related to Secure Boot:

s2disk: Could not open the snapshot device. Reason: Operation not permitted 

However, please understand that this is not a place to complain and please be nice.

Related questions

LiveWireBT
  • 28,763
  • 3
    Thanks for the method, but I'm still having no success after a reboot and after 'killall indicator-session-service'. You did mention "or do other troubleshooting after reboot", though, so I guess I'm in that category. It's very strange to find such an important behavior still unsupported after so many iterations of this operating system, but that's all the rant I've got at the moment. I'll just cross my fingers and stick with sudo pm-hibernate for now. – cdaddr Nov 01 '13 at 20:08
  • 3
    A couple of questions: why in the world is hibernation disabled? And does doing the above avail hibernation options in Power Settings? I don't need hibernation in the gear menu, but for the my laptop to hibernate at critical battery levels. Thanks for the answer! – Oxwivi Dec 20 '13 at 14:28
  • I'm not responsible for this change but the initial question here on AskUbuntu contains a link to a bug report that suggests disabling suspend/hibernate instead of tracking which hardware "certifies" for for what power modes, since that approach seems to be more scalable. I would rather blame the manufacturers here. I have hibernate as an option for what to do on critical battery levels on my desktop, but couldn't replicate this in my VM to add a proper english screenshot. – LiveWireBT Dec 21 '13 at 09:18
  • 1
    I am not able to hibernate even after this!! :( please help! hibernation works on my machine...but not showing in the menu.. – Nirmik Feb 03 '14 at 23:35
  • I upgraded from 13.04 and have no such file: ➜ ~ sudo ls /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla ls: cannot access /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla: No such file or directory. Should I just create it? – Michael Pankov Feb 16 '14 at 09:43
  • 1
    @constantius Yes, you should create it. – LiveWireBT Feb 16 '14 at 09:56
  • Doesn't fix hibernate being missing from power settings :( – Salman Apr 17 '14 at 13:54
  • @SalmanPK Did you try any of the other answers? – Seth Apr 17 '14 at 14:24
  • @Seth, yup to no avail. – Salman Apr 18 '14 at 01:01
  • 1
    @SalmanPK You might ask another question then. Also make sure you have enough SWAP. – Seth Apr 18 '14 at 01:04
  • @Seth Actually, I just tried the "Related question" and it worked, thanks! Now my laptop hibernates on closing lid. \o/ – Salman Apr 18 '14 at 01:07
  • @SalmanPK Can I know which one? – Seth Apr 18 '14 at 01:07
  • @Seth This: http://askubuntu.com/questions/15520/how-can-i-tell-ubuntu-to-do-nothing-when-i-close-my-laptop-lid

    It's actually about doing nothing on closing the lid but I tailored it to hibernate instead.

    – Salman Apr 18 '14 at 06:08
  • Is this necessary on 14.04? – John Scott Jul 23 '14 at 16:52
  • Hi,

    Thanks for the recipe.

    I would like to leave some traces of the modifications. Do you know how can I add comments in the pkla file?

    – Mathieu Dubois Aug 21 '14 at 18:44
  • @MathieuDubois Have you tried using #? It seems to be valid for PolicyKit .conf files like /etc/polkit-1/localauthority.conf.d/50-localauthority.conf, ; may also work or be worth a try as the format looks similar to INI – LiveWireBT Aug 21 '14 at 19:48
  • Thanks for your answer. Unfortunately, INI is rather loosely defined. Anyway I have added some comments with # in order to test. Do you know how can I see if there is a problem (log file, etc.)? – Mathieu Dubois Aug 26 '14 at 19:08
  • Is there a similar method for Sleep as well? the sleep option disappears once you clicked shutdown. – Rápli András Feb 28 '15 at 06:10
  • @RápliAndrás That sounds like different bug, that should be reported. – LiveWireBT Feb 28 '15 at 10:06
  • This also works for 14.04 with Xfce... – landroni Mar 31 '15 at 21:38
  • 1
    Thank you for the hint about Secure Boot. You should put that section in bold. I was going out of my mind trying to figure out why I could not hibernate after cloning my hard drive. – mcchots Oct 25 '16 at 14:41
  • I totally forgot to ensure that my Secure Boot is disabled until I see this answer. – J3soon Jun 18 '17 at 06:33
2

If you still have problems in making hibernate work, check comment #58 on this bug report:

I found a workaround on ubuntu gnome 13.10: just install hibernate:

sudo apt-get install hibernate

The only problem is that apport will issue three errors when starting up after normal Power Off. For this you can disable apport:

sudo -H gedit /etc/default/apport

Then change enabled=0.

To change settings from hibernate edit files in /etc/hibernate.

Installing hibernate package seems to make the right changes and it worked very well for me in ubuntu gnome 13.10 x64

pa4080
  • 29,831
1

If you have followed the previous steps and it still hasnt worked, I suggest that you change your /etc/pm/sleep.d/20_custom-ehci_hcd to:

[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

to make it work, then follow the steps mentioned above to enable the hibernate option. This really worked for me.

At the end you are gonna have 2 files edited with "[Re-enable hibernate ... ]" Try this one. It will work for sure if you are using ubuntu 13.10

LiveWireBT
  • 28,763
nba-crash
  • 11
  • 1
1

One thing I would like to add here, which AFAICR, is unmounted swap partition. If the swap partition is not mounted the hibernate option will not be displayed/enabled irrespective of the hibernation configuration.

And if the swap partition doesn't automount then the hibernated session would be lost.