Ubuntu – Another question about Hibernate in 18.04 (not a duplicate)

hibernatepm-utilspower-managementshutdownsuspend

I have a fresh install of 18.04 on a brand-new high-end laptop. Hibernate works using

sudo pm-hibernate

By "works" I mean that it saves the system to disk, and powers down. Upon reboot, the session is resumed at exactly the point I left, including the last terminal command being pm-hibernate.

During shutdown it reports:

s2disk: Snapshotting system

I tried to follow various instructions and many SE answers about installing Hibernate as menu option and to trigger upon the power button.

The main one is this reference on 18.04 and this one for 17.10.

One expects pm-hibernate to work. The other expects the command to be

sudo systemctl hibernate

But systemctl hibernate does not work for me. It reports different text output to the console as it shuts down (something about Alarms can be one month in the future.) Upon re-boot, it's a full-fresh boot-up, with Chromium complaining it was shutdown ungracefully.

I have a Hibernate option in the shutdown menu thanks to this plugin and I have a Hibernate option under Power Settings.

How do I get these GUI options to use the Hibernate which works – the pm-hibernate – instead of the broken Hibernate?

Menu Option
Power Settings

Best Answer

Take a look at: ubuntu 18 hibernation using the power button

and https://medium.com/@lzcoder/enable-hibernate-on-ubuntu-using-uswsusp-s2disk-ae0b71862eb5

In summary:

# [terminal] initial basic steps
sudo apt install uswsusp                  # working hibernate
sudo apt-get install chrome-gnome-shell   # for button

# [chrome] to activate in chrome
https://extensions.gnome.org/extension/755/hibernate-status-button/#

# [terminal] modify this file 
cd /lib/systemd/system
sudo gedit systemd-hibernate.service 

# to copy and add to file, leaving only this service
[Service]
ExecStart=
ExecStartPre=-/bin/run-parts -v -a pre /lib/systemd/system-sleep
ExecStart=/usr/sbin/s2disk
ExecStartPost=-/bin/run-parts -v --reverse -a post /lib/systemd/system-sleep

Source: http://ubuntuhandbook.org/index.php/2018/05/add-hibernate-option-ubuntu-18-04/

# [terminal] create file to allow button in menu

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

#add to file
[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.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes

# [terminal] reload services
sudo systemctl daemon-reload
Related Question