Hibernation aka suspend to disk

What is hibernation?

Hibernation, also known as suspend to disk, is powering off a computer while retaining its state. In hibernation, the computer needs no power: it can be unplugged. After turning the computer on again, the system is exactly as it was before entering hibernation.

Warning: a number of computers do not properly wake up from hibernation. It is recommended to save your work before hibernating.

Prerequisite

Hibernation requires a swap partition at least as large as the main memory. The rest of this manual assumes the existence of one single such partition. Executing the following command in a terminal shows how much "Mem" and "Swap" the system has in "total" (first column):
$ free
If the system has no (or a too small) swap partition, it can be created (or enlarged) from a GNU/Linux live system such as Trisquel's, for instance using GParted, which is a graphical interface to GNU Parted.

Setting up hibernation

To hibernate/resume Trisquel 11, Linux must be given the identification of the swap partition. Executing those commands in a terminal does that:
$ sudo sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"/&resume=UUID=$(blkid | grep swap | cut -d \" -f 2) /" /etc/default/grub
$ sudo update-grub

After a reboot, the following command would hibernate the system:
$ systemctl hibernate
However, it would ask for the password of a user with administrative privileges, what also prevents the integration into desktop environments. To avoid that, executing the following command in a terminal adds a Polkit rule:
sudo tee /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla << EOF
[Enable hibernate in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Enable hibernate 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
EOF

If you are using GNOME Shell, install this extension, which adds a Hibernate button in the Status menu. To do so from Abrowser, you may need to install the package chrome-gnome-shell, which is available in the Trisquel repository, and to enable this add-on.

Revisions

04/14/2023 - 01:38
Magic Banana
05/02/2023 - 10:14
prospero
08/03/2024 - 11:07
Avron
09/22/2024 - 02:39
knife