This is a step by step beginner’s guide shows how to enable hibernation feature in Linux Mint. Though, the title said for Mint 22, it should also work in Linux Mint 21 & 20.
Hibernate moves all data from RAM into disk, then shuts down the computer. It uses less power than suspend which sleep to RAM. However, hibernate might NOT work for some PCs and in-compatible with secure boot, so it’s NOT enabled by default in most Linux.
To enable hibernate feature in Linux Mint, you need to do following steps one by one:
- First, disable secure boot in BIOS.
- Find out where is your Swap space, then tell Linux Kernel to resume from it on startup.
- Add ‘hibernate’ option into shutdown menu.
Step 1: Disable Secure Boot
The BIOS setting option for secure boot differs depends on your motherboard. So, I will not include the how-to here.
But to tell if secure boot enabled or not, you may press Ctrl+Alt+T
to open terminal, and run command:
sudo mokutil --sb-state
Step 2: Locate the Swap device
Hibernate will try to store data into swap space in your disk. You need to find out where it is, before enabling this feature.
1. First, open terminal (Ctrl+Alt+T) and run command to show swap devices:
sudo swapon
In the output, you’ll see:
- either swap partitions, e.g.,
/dev/sdXY
or/dev/nvmeXnYpX
. - or swap file, such as
/swapfile
If more than one swap devices available, the one with high “PRIO” (priority) is needed.
If you see /dev/zramX
in the output, then it does NOT support hibernation, since the swap device is available in RAM rather than in disk.
2. If your swap type is “file” (see the screenshot above), then you need to first run the command below to find out where is the root partition:
df -h
In the output, find out the device mounted on /.
Finally, run one more command to find out the start of physical offset of that swap file (replace /swapfile to yours, according to sudo swapon
output).
sudo filefrag -v /swapfile
In my case, the swap file is on root (/dev/sda5), and the physical offset starts at 63406080.
Step 3: Add Kernel Parameter to resume from Swap
To easiest way to load kernel parameter at startup is using the default Grub boot-loader.
1. First, open terminal (Ctrl+Alt+T) and run command to edit the Grub config file:
sudo xed /etc/default/grub
2. When file opens, find out the line “GRUB_CMDLINE_LINUX_DEFAULT”, then add the value below:
- If swap type is partition, then add resume=/dev/xxx (replace xxx according to
sudo swapon
output). - If swap type is file, then add resume=/dev/xxx resume_offset=xxxxxxxx. In the case,
/dev/xxx
is the root partition.
3. After saving the file, run the command below to apply!
sudo update-grub
Step 4: Add ‘Hibernate’ option to shutdown menu
For Linux Mint 22, simply run the command below in terminal to create & edit the config file:
sudo xed /etc/polkit-1/rules.d/10-enable-hibernate.rules
When file opens, add the lines below and save file:
polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.login1.hibernate" || action.id == "org.freedesktop.login1.hibernate-multiple-sessions" || action.id == "org.freedesktop.upower.hibernate" || action.id == "org.freedesktop.login1.handle-hibernate-key" || action.id == "org.freedesktop.login1.hibernate-ignore-inhibit") { return polkit.Result.YES; } });
For old Linux Mint 21 and earlier, open terminal (Ctrl+Alt+T) and run command to ensure the polkitd-pkla
package is installed.
sudo apt install polkitd-pkla
Then, run command to ensure the required directory exist:
sudo mkdir -p /etc/polkit-1/localauthority/50-local.d
Finally, create and edit the config file via command:
sudo xed /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
When file opens, add the lines below and save 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
If everything’s done without error, you can now try to open shut-down menu and click “Hibernate”. When system goes down, press power button and see if it restores your system to the previous state.