The hibernate functionality is disabled in Ubuntu by default because it might not work on some machines. For those who want to re-enable the feature, here’s how to do it in Ubuntu 17.10.
1. Test if hibernate works on your machine.
Open terminal either via Ctrl+Alt+T keyboard shortcut or by searching ‘terminal’ from application launcher. When it opens, run command:
sudo apt install pm-utils && sudo pm-hibernate
After you computer turns off, switch it back on. Did your open applications re-open? If hibernate doesn’t work, check if your swap partition is at least as large as your available RAM.
2. To re-enable hibernate, run the command to edit the configuration file:
sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
When the file opens in the terminal window, scroll down to find out the section started as:
“[Disable hibernate by default in upower]” and “[Disable hibernate by default in logind]”
Change the both values of ResultActive to yes.
Save the changes by pressing Ctrl+X and then typing y and finally hitting Enter.
To make Hibernate working for multiple users, you can add following lines into the configuration file:
[Re-enable hibernate for multiple users by default in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate-multiple-sessions ResultActive=yes
And for some machines you may replace the command in step 2, in case it doesn’t work, with following one:
sudo nano /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
Press power button to hibernate:
After enabled the hibernate functionality, you can launch Settings from application tool. In the ‘Power’ settings, you are able to set ‘Hibernate’ when the power button is pressed.
Hibernate when laptop lid is closed:
You can also make your laptop automatically hibernate when the lid is closed.
To do so, open terminal (Ctrl+Alt+T) and run command to edit the logind.conf file:
xhost +local: && sudo gedit /etc/systemd/logind.conf
When it opens, change the line
#HandleLidSwitch=suspend into HandleLidSwitch=hibernate.
Tip, you can replace the value of HandleLidSwitch to
ignore for other lid closed actions.
To apply all the changes, restart your computer.