6

I'm using Ubuntu 16.04 and am having trouble hibernating. I have a 16 GB swap file (size of my ram) that is enabled and working, but what sudo pm-hibernate does is turn my screen off for a moment then back on, freeze the whole thing for another moment or two and then put me on a new line in terminal like nothing ever happened. Hibernating from the menu in Unity shuts off the screen for like 5 seconds and then puts me at the log-in screen. My session is still active though. Any help would be appreciated as I pretty much can't live without hibernation. This feature worked flawlessly under Windows 10.

PC is a HP Pavilion 17-F211NG with a Core i7 5500U and 16 GB of RAM.

Max
  • 81
  • Hibernating is a function of the OS, not the hardware. The fact that it working in Windows 10 means absolutely nothing. Also, I believe (unless things have changed) that hibernation is disabled by default. And there's a reason for that: It's very buggy. Besides, you have suspend. – You'reAGitForNotUsingGit Aug 30 '16 at 17:51
  • 2
    I mentioned WIndows 10 exactly for this reason, to prove my hardware isn't faulty. Suspend keeps the ram on and drains battery, in my case suspending the laptop at night halves the battery by morning. – Max Aug 30 '16 at 18:13
  • Well that probably means the computer is going into an S3 suspend instead of a more power efficient suspend like S5. – You'reAGitForNotUsingGit Aug 30 '16 at 18:14
  • 1
    Sorry, but I'm not familiar with different suspend states. I'd just really like to get hibernation working. I feel best when I know that the hardware is completely turned off. – Max Aug 30 '16 at 18:18
  • Well, if you want to get some help, you really should include the model of your computer :) – You'reAGitForNotUsingGit Aug 30 '16 at 18:23
  • Edited the question :) – Max Aug 30 '16 at 18:30
  • Log might just have some info : dmesg|grep 'boot\|hib\|shut\|swap\|image' . The documentation for hibernate does say that swap size should be at least as much as ram. Maybe just as much is not enough in all cases. – R.S. Oct 09 '16 at 05:16

2 Answers2

4

Since you're running Ubuntu 16.04, you should consider running the native systemd suspend/hibernate services in lieu of the pm-utils tools.

In my own case, here's what I've done to configure my machine for hibernate/resume using systemd:

  1. In etc/default/grub, configure GRUB_CMDLINE_LINUX_DEFAULT to include the resume parameter, passing the UUID of the swap partition in question (i.e., resume=UUID=453f0121-505d-42d3-8dad-87f913e67ddc). My current GRUB_CMDLINE_LINUX_DEFAULT is

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi resume=UUID=453f0121-505d-42d3-8dad-87f913e67ddc"

  2. Run sudo update-grub

  3. Edit/confirm resume=UUID=453f0121-505d-42d3-8dad-87f913e67ddc entry in resume file located in /etc/initramfs
  4. Run sudo update-initramfs -u
  5. Edit /etc/systemd/logind.conf to set HandleLidSwitch=hibernate (optional: permits hibernate to start on lid close)
  6. Run sudo service systemd-logind restart
  7. Reboot for good measure

I've bold-faced the two parameters that--for my machine--are important: pci=nomsi and resume=UUID=[your swap partition]. While the latter parameter is pretty well understood and is often refenced when talking about enabling hibernate on a Debian system, it took a bit of discovery to find the need for the former.

Best of luck!

richbl
  • 2,303
  • I've just managed to make my laptop hibernate, your answer with a little bit of help from archwiki was enough to make it work. But after hibernation I have some problem with the system. If you could take a look and give a hint what may be going on: https://ubuntuforums.org/showthread.php?t=2403905&p=13809298#post13809298 – kujaw Oct 17 '18 at 17:40
0

In case it helps, here is the procedure I followed on Ubuntu 14.04. I have not tried it on 16.04 yet but it worked like a charm on my hardware with 14.04:

  1. Save your work and use the command line to test if hibernate works on your computer: open the Terminal by pressing Ctrl+Alt+T or by searching for terminal in the Dash. Type sudo pm-hibernate into the terminal and press Enter. Enter your password when prompted, and press Enter again. After your computer turns off, switch it back on. Are the applications that were running before hibernate still running? If hibernate doesn't work, check if your swap partition is at least as large as your available RAM.

  2. If the hibernate test works, you can continue to use the sudo pm-hibernate command when you want to hibernate.

You can also enable the hibernate option in the user menus. To do that, use your favorite text editor to create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla. Add the following to the file and save:

    [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;org.freedesktop.login1.hibernate-multiple-sessions
    ResultActive=yes

(Source: https://help.ubuntu.com/14.04/ubuntu-help/power-hibernate.html)

TheOdd
  • 3,012
boba
  • 173
  • In 16.04 I also had to add the resume partition in the GRUB_CMDLINE_LINUX_DEFAULT line in /etc/default/grub in order to resume properly after hibernate. In my case, the line now reads: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/ubuntu-gnome-vg/swap_1". I am using LVM (Logical Volume Manager), be sure to check the actual path to your swap partition and add it after resume=. – boba Oct 11 '16 at 18:46