Is there any way to add "Hibernate" to the power menu in Hera as in Freya? "sudo systemctl hibernate" works perfectly.

  • I haven't tested it, I'm nowhere near that PC right now, so I'll just link it here. That may still work, though it's a bit old. A glance over it and I don't see any reason why it wouldn't work, unless eOS changed that since then. – KGIII Nov 20 '20 at 5:11
  • Did that work for you? – KGIII Nov 22 '20 at 23:15
  • Well,no. The "sudo systemctl hibernate" doesn't work.Just found it out now – Prajul Nov 25 '20 at 7:32

The hibernate button was recently removed because it had stopped working due to some changes in Ubuntu (upon which Elementary is based). Like many others, suspend doesn't work very well on my PC, so it's very important to me that hibernate work properly.

Fix Resume-From-Disk

At least in my experience, if you try to run systemctl hibernate after a fresh install of Hera, the system will happily suspend itself to disk. But it will not actually resume after pressing the power button; instead, it performs a fresh boot as if you had simply cut the power instead of hibernating.

The issue is that the kernel does not know how to find the swapfile during early boot, so it is unable to detect that the system was previously suspended. To fix this, we need to provide details about the system's swapfile using the resume and resume_offset kernel parameters.

These instructions were taken from the Arch Wiki page on hibernation.

First, determine the partition UUID and disk offset of your swapfile:

$ findmnt -no UUID -T /swapfile
$ sudo filefrag -v /swapfile | awk '{ if($1=="0:"){print $4} }'

Then, open /etc/default/grub in a text editor and add the resume and resume_offset kernel parameters to the value of GRUB_CMDLINE_LINUX_DEFAULT as follows, replacing <uuid> and <offset> with the values from the previous step.

GRUB_CMDLINE_LINUX_DEFAULT="... resume=UUID=<uuid> resume_offset=<offset>"

Finally, you must run sudo update-grub in order for changes to /etc/default/grub to take effect.

ACPI Events

When on battery power, I like for my laptop to hibernate when the lid is shut. I also like for the power button to trigger hibernation regardless of whether on AC or battery power. This is easy enough to achieve by creating a custom ACPI event handler.

Before you set this up, be sure to disable any power button or lid close events in the System Settings app, as these could interfere with the new event handler and cause unwanted behavior.

First, create the file /etc/acpi/events/hibernate with the following contents:


Then, create the file /etc/acpi/hibernate.sh. This script will be executed any time an ACPI event occurs. Add the following lines to trigger hibernation as outlined above, or feel free to do something different if you wish!


case $1 in

        # Hibernate when power button is pressed
                /bin/systemctl hibernate

        # Hibernate when lid is shut while on battery
                if [ $3 = close ]
                        AC=$(cat /sys/class/power_supply/AC0/online)
                        if [ $AC = 0 ] # AC adapter not connected
                                /bin/systemctl hibernate

        # Hibernate when AC adapter is unplugged while lid is shut
                if [ $4 = 00000000 ] # unplugged
                        LID=$(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}')
                        if [ $LID = closed ]
                                /bin/systemctl hibernate

Finally, mark the new script as executable, then send a signal to acpid to load the new event handler:

# chmod +x /etc/acpi/power.sh
# systemctl kill -s HUP acpid

Expand Swap File

Hibernation works by storing the state of all open programs to the swapfile, which can fail if the file is not large enough.

Hera appears to create a 2GB swapfile by default, which may not be large enough to support hibernation if you do a lot of multitasking. A good rule of thumb is for your swapfile to be at least as large as RAM.

Here's how to expand your swapfile to 8GB. For different sizes, just tweak the dd command options.

# swapoff /swapfile
# dd if=/dev/zero of=/swapfile blocksize=1M count=8192
# mkswap /swapfile
# swapon -a

Note resizing the swapfile may change its disk offset, requiring you to use a different value for the resume_offset kernel parameter.

Official Support

Searching GitHub is a great way to understand the status of certain features from the developers' perspective. Here's a query that shows all the activity related to the keyword "hibernate":


Looks like there are some open PRs to get the hibernate button working again in the UI. For the latest updates, I'd recommend subscribing to notifications for this PR:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.