Tags


How to enable hibernation in three simple steps

First written on October 22, 2017
Last updated on September 13, 2021

Greetings to all,

It has been some time since I needed to enable hibernation on my machine so that I could find all my stuff exacly as I left it the previous time. This is especially useful to me since I usually leave multiple terminals opened. So, untill recently, I suspended instead of hibernate, but that is not always practical.

What follows is a summary of instuctions I gathered from multiple sources and it reflects my use case and configuration.

Prerequisites

Step 1

Get the UUID of your swap partition.

# UUID="$(blkid | grep swap | awk '{print $2}' | tr -d "\"")"

Step 2

Edit the /etc/mkinitcpio.conf file to include resume after udev in the HOOKS section. This is how mine looks:

HOOKS="base udev mdadm_udev lvm2 resume autodetect modconf block filesystems keyboard fsck"

Then we must regenerate the ramdisk environment (please get the correct kernel names first). For example:

# mkinitcpio -p linux-libre
# mkinitcpio -p linux-libre-lts

Step 3

Copy the variable you gathered earlier.

$ echo $UUID

Append the resume kernel parameter to your bootloader configuration. For example, this would be a modified Syslinux entry to accomodate the new parameter.

LABEL <some label>
    MENU LABEL <some value>
    LINUX <some other value>
    APPEND <yet again other values> resume=<paste the $UUID variable here>
    INITRD <and again>

Testing

$ systemctl hibernate

That’s it.

Enjoy.


Post a new comment