Hibernate after suspend (on Fedora)

I recently found out that Windows has this nice feature where, after suspending your laptop, it’ll go to hibernate after a while to preserve battery. Seems like a really cool feature, saves your battery too, so I wanted it on my linux installation. I’m using Fedora 27 right now.

To get it working, you’ll first need to verify that your suspend to ram and suspend to disk actually work. There are plenty of articles on the web that can guide you through it.

The solution is relatively easy, thanks to the internet ;) I got most of the info here, on the ArchLinux forums / wiki. create the following systemd unit file (in /etc/systemd/system), called suspend-to-hibernate.service. After some testing I ended up with this file:

Description=Delayed hibernation trigger
Conflicts=hibernate.target hybrid-sleep.target

ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '\
 alarm=$(cat $WAKEALARM); \
 now=$(date +%%s); \
 if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then \
 echo "hibernate triggered"; \
 systemctl hibernate; \
 else \
 echo "normal wakeup"; \
 fi; \
 echo 0 > $WAKEALARM; \


Afterwards, enable it through systemctl enable suspend-to-hibernate.service; start it through systemctl start suspend-to-hibernate.service and you should be good to go.

Bookmark the permalink.


  1. Thanks for your instructions, Jan!

    I am currently in the process of implementing them on Fedora 28.

    I followed all steps but my system did not wake up after 30 minutes to hibernate.

    Am I missing something?

    Could you give me some advice?

    Thank you!



  2. Pingback: Fedora 29: switch from suspend to hibernate automatically – Robert Orzanna

  3. The only thing I can readily think of is that your device is not set to wake up in the BIOS – it requires that your machine can be woken by RTC alarms. Which device is it?

  4. Hey Jan,

    Indeed, I changed some BIOS settings and now it’s fully working with my Thinkpad X230.

    What a great solution you shared.

    Much appreciated!


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.