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.
Thanks for the tip.
I searched a lot to enable this and this tip did it.
This worked for me using linux Mint 22.
So i created the file with
sudo xed /etc/polkit-1/rules.d/10-enable-hibernate.rules
However I also needed to install
sudo apt install polkitd-pkla
which was described for linux Mint 21
because it was not installed on my machine.
Kind regards!
Michiel Vanhoutte
Hi Ji, thanx a lot for this! I managed to get hibernation running in Mint 22 on my little Zotax box that I want to place in my minicamper where simple suspend would be a waste of electricity.
But since I wanted a swap file on an encrypted disk (I can confirm that this works very well), I used step 3 from this HowTo in the Mint forums first and then continued with yours:
https://forums.linuxmint.com/viewtopic.php?t=284100
I think it would be great if you could incorporate this step of creating and activating a swapfile into your HowTo. Also, I needed to set the priority of that swapfile in fstab to 1 because it was set to minus 2, and hence, it was not used at all.
Another little thing is that maybe it should be clearer that after the section starting with “For old Linux Mint 21 and earlier,…”, ALL the following steps are meant ONLY for 21 and earlier, not only the one step with that line. That’s not so obvious for people who are not familiar with the process. 😉
Regards,
Harry
Amazing. Really well written and formatted. This worked the first time, and now I don’t have to leave my battery in the laptop all the time, just to use “suspend”, in case I might need it.
Besides that, “suspend” on this particular laptop doesn’t seem to reduce power consumption much if at all, so now I can shut off the laptop with “hibernate” and just pick up right were I left off after restarting.
I agree with “Harry” (October 1, 2024 at 12:05 pm): ‘Another little thing is that maybe it should be clearer that after the section starting with “For old Linux Mint 21 and earlier,…”, ALL the following steps are meant ONLY for 21 and earlier, not only the one step with that line. That’s not so obvious for people who are not familiar with the process.’
I’m on Mint22, but I had to read this part three times to make absolutely sure that I could just skip the whole thing.