Linux Mastering Development

Guide on how to enable hibernation on Linux Mint 20 Cinnamon (Ubuntu 20) and prevent unwanted wakeups

This is, in a way, a memo for myself in the future. I do not understand why hibernation on linux is not a simple feature that just works and why enabling it has to be so complicated. I hope it also helps people having questions about hibernation.

  1. First, you need to make sure you have a large enough swap file. Swap is where your RAM is save on disk when you hibernate.
  • Check the size of your swap either through System Monitor -> Resources or by running sudo swapon --show. You probably do not have enough. Your swap size should be somewhat larger than you RAM size. There are some guides online. I go for 5GB swap on my 4GB RAM machine.
  • How to make your swap larger depends on how you have it set up. Maybe you need to create a larger swap file, maybe you need to open GParted and simply resize partitions there. I have an encrypted LVM with /dev/vgmint/root and /dev/vgmint/swap volumes. You cannot resize LVM while it is mounted, so you boot from a USB stick with Linux Mint. There you can use Disks app to unlock your encrypted LVM and use this beautiful guide to safely reduce the size of your /dev/vgmint/root volume:
    • Force check file system sudo e2fsck -f /dev/vgmint/root
    • Shrink your file system sudo resize2fs /dev/vgmint/root 180G. Replace 180G with about 90% of the size you want the final volume to be.
    • Reduce your volume to it’s final size sudo lvreduce -L 200G /dev/vgmint/root, where 200G is your volume’s final size.
    • Grow your file system to take up the rest of the free space of your volume sudo resize2fs /dev/vgmint/root
  • Then you can run sudo lvextend -l 100%FREE /dev/vgmint/swap_1 to extend your swap volume with the free space you have just created.
  • Now, we need to update swap. We are done with a USB stick live system, boot into your regular system. If you check the size of your swap again, you will see that the size of it has not changed, even though we just gave it more space. We need to create a new swap. Run sudo swapoff -a to disable all swaps and run sudo mkswap /dev/vgmint/swap_1 to create a new one.
  1. Now, test if your hardware supports hibernation and add hibernation button back by reading this lovely article:
    • Open terminal, run sudo pm-hibernate. Your computer should hibernate. Boot it up again and make sure it restores everything. If it does, than your hardware supports hibernation.
    • Now, we will enable hibernation icon. Create file:
      sudo -i
      cd /var/lib/polkit-1/localauthority/50-local.d/
      nano com.ubuntu.enable-hibernate.pkla
    • Paste the following content into that file:
      [Re-enable hibernate by default in upower]
      [Re-enable hibernate by default in logind]
    • Save, restart. Now you should have "Hibernate" option when you press your power button.
  2. Power management. This is probably specific to Linux Mint with Cinnamon. I want my laptop to hibernate after a certain period of inactivity, but it is not possible to set this up using Power Management app. To edit inner Cinnamon settings, I use dconf editor (sudo apt install dconf-editor). Open it up, go to /org/cinnamon/settings-daemon/plugins/power/ or just search for power. sleep-inactive-battery-type is what I am after – set it to ‘hibernate’. While here, I like to turn off use-time-for-policy and use battery percentages instead of time remaining to determine "battery low", "battery critical" and "battery action" states. Battery percentage is a real value, while time remaining is an estimate and can vary a lot. You can also set percentage thresholds using percentage-low, percentage-critical and percentage-action. Take a look a round, there are some interesting settings in this tab. Be careful though.
  3. Now, the last piece of the puzzle prevent unwanted wakeups from suspend/hibernation. Write sudo cat /proc/acpi/wakeup. You will see which devices are enabled and can lead to unwanted wakeups from hibernation. Devices that cause you trouble need to be disabled on boot and on return from suspend/hibernation.
  • Here is how to disable a device: echo DEVICE_NAME | sudo tee /proc/acpi/wakeup. (Thanks to this thread.)
  • Figure out which devices cause you problems (I have disabled all) and write a bash script that would disable them. (File might need to be owned by root, since root will be executing it.) It would look something like:

echo RP01 | tee /proc/acpi/wakeup
echo RP02 | tee /proc/acpi/wakeup
echo RP03 | tee /proc/acpi/wakeup
echo RP05 | tee /proc/acpi/wakeup
echo RP06 | tee /proc/acpi/wakeup
echo XHC1 | tee /proc/acpi/wakeup
echo LID0 | tee /proc/acpi/wakeup

Do not forget to make your script executable for root. sudo su and then chmod +x /

  • Now, we need to create a systemctl service that will be calling the script. (Thanks to this article and many other posts on this website for inspiration). I call the service wakeups. Create the file using sudo nano /etc/systemd/system/wakeups.service. The contents of the file:
Description=Fix unwanted wakeups from suspend


  • Enable the service by running systemctl enable wakeups.service
  1. Alright, that is all it takes to have hibernate properly functioning! Test and make sure everything works correctly when booting regularly and when returning from hibernate/suspend.

Leave a Reply

Your email address will not be published. Required fields are marked *