In this article I will show you how to enable hibernation on Ubuntu 14.04 Trusty Tahr, and add the Hibernate button in the shutdown menu.
As you may know, via the hibernation process all the data stored in the RAM memory gets moved on the swap memory (on the hard disk). In order to properly enable hibernation, make sure your swap memory is at least as big as the RAM memory.
While hibernation can be easily done via the command-line, you can also make some tweaks to get the Hibernate button into your shutdown menu.
Open /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla as root (or with sudo) in your favourite text editor:
sudo vim /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Paste the below lines in the recently opened 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 ResultActive=yes
Optional, to make your laptop hibernate when you close the lid, paste the below oneliner in the terminal:
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=hibernate/g' /etc/systemd/logind.conf
The sed command only modifies #HandleLidSwitch=suspend to HandleLidSwitch=hibernate, in the /etc/systemd/logind.conf.