49

I have a fresh install of 16.04.1 on a Lenovo T450s that always worked fine with respect to suspend/hibernate on Ubuntu (previous version I used was 14.04.5). Swap is comfortably bigger than RAM on this install.

As I am used to now, after the install I tried to go on with the usual hack for hibernation activation. However, things seem to be different this time as sudo pm-hibernate does not seem to do anything.

As far as I understand, now that ubuntu has switched to systemd, the correct command would be systemctl hibernate which returns

 Failed to hibernate system via logind: Sleep verb not supported

I tried the solutions mentioned here, but they are mostly aimed at re-enabling pm-hibernate and making it an entry in the logout menu. I also saw that one possible solution is to install the Tuxonice kernel, but did not try as I am not very keen on tampering with the kernel in general and using a PPA kernel in particular.

So, is there a way to reactivate hibernation on the last, systemd-based versions of Ubuntu? Preferably using systemd, and avoiding potentially system-breaking hacks. Or do I just have to wait and hope until the next update?

Marc
  • 1,252
  • 1
    Yes, I tried. The thing is it is not that hibernation fails, say the system hangs while shutting down or fails to thaw. It is just that nothing happens when I fire systemctl hibernate (with or without sudo), except this message Failed to hibernate system via logind: Sleep verb not supported. – Marc Jan 06 '17 at 23:24
  • Swap is up and working well, no problem there. I tried the grub thing anyways just to be sure. No luck. – Marc Jan 08 '17 at 08:55
  • FWIW, sudo pm-hibernate still works on 16.04... usually. From your answer below, It seems that hibernating doesn't really work with Secure Boot, but if it did, pm-hibernate would definitely work as expected. Of course, you could also use the systemctl command as well. – TSJNachos117 Sep 17 '17 at 05:13
  • Shame the message did not read: Failed to hibernate system via logind: Please use BIOS to disable secure boot – Bad Loser Nov 05 '19 at 21:22

2 Answers2

55

I was finally able to solve my own problem following some topics on Fedora (they made the switch to systemd a while ago so there's more material there).

It turns out that I had secure boot enabled (I recall being asked about that during 16.04 install, and that I kept it on without giving it much thought) and that caused the output of cat /sys/power/disk to be:

 [disabled]

Indeed not a very good sign. So I rebooted and went searching in my BIOS settings, disabled secure boot there. Now cat /sys/power/disk gets me:

 [platform] shutdown reboot suspend 

which looks better. And indeed calling systemctl hibernate results in a successful hibernate/thaw sequence.

Moreover, the option to hibernate now shows up in the graphical interface without the need for any hack (at least on my computer).

Marc
  • 1,252
  • 1
    Thanks man. You saved my day. I really thank you. Thank you thank you. – Khamidulla Feb 27 '17 at 01:39
  • 4
    This should be added in the Ubuntu documentation here: https://help.ubuntu.com/stable/ubuntu-help/power-hibernate.html – Joaquín Aramendía May 12 '17 at 15:18
  • Thanks. It worked for me as well with Ubuntu 16.04 on asus zenbook apart that menu option for hibernating in graphical interface still is missing. – Wojteks Jun 06 '17 at 06:37
  • Just FYI, if your disk setting is not the reason or the answer doesn't fix your error, try enabling your swap space and make sure it is reasonably sized over your total installed physical RAM. That did it for me! – der_michael Aug 15 '17 at 05:20
  • Thanks for the comment, but the swap was on and generously sized in my case. – Marc Aug 16 '17 at 05:42
  • This works in Ubuntu 17.04 and the GUI icon for hibernate is back ! Thanks a lot ! – Swaroop Feb 06 '18 at 17:58
  • This didn't work for me, Ubuntu 18.04, Thinkpad X1 Carbon Gen 7. – SaTa Sep 25 '19 at 23:33
  • 1
    this answer to similar question explains in details why hibernate does not work with secure boot: it is intentionally disabled as there's currently no way to verify resume image saved in swap (so enabling it would give a false impression of security) – morgwai Apr 23 '20 at 09:01
  • THANK YOU! I'm on linux mint with XFCE, I changed the swap and did several other changes and settings, everything was looking right but it would still not let me hibernate. This solved my issue! I wish this page came earlier for me when searching the internets... – msb Jan 12 '22 at 04:55
22

This can also happen when your swap is too small to hold your RAM contents (e.g. when you added more RAM to your computer after setting up the OS).

Check e.g. in htop, then Mem number should be <= the Swp number.

See https://github.com/systemd/systemd/issues/6729

nh2
  • 1,621
  • 1
    Thanks for your suggestion, but this was not the problem in my case. It was discussed in the comments. I will update the main text to make it even clearer. By the way, I do not understand why this is always the first thing people suggest regarding fixing hibernation, while the standard ubuntu install will usually come out with the right amount of swap, unless you voluntarily tampered with it. – Marc Sep 17 '17 at 04:24
  • 1
    @Marc Like I said in the answer: Even if the Ubuntu install picks the right amount of swap at the time of the installation, it is very common for people to just buy another RAM stick and plug it into the computer after the installation (e.g. upgrade from 8 GB to 16 GB RAM a year after you bought and installed the machine). – nh2 Sep 17 '17 at 14:08
  • 1
    that was my case! I increased the size of the swap file(my ubuntu uses a swapfile instead of a swap partition) using this procedure: https://bogdancornianu.com/change-swap-size-in-ubuntu/ – Bruno Negrão Zica Apr 01 '20 at 23:31