Recently I discovered that Windows has a pretty cool feature – after sleeping for a while the system will automatically hibernate. This is a pretty nice feature for a laptop, you just close the lid and after a while it will automatically turn off. Yes it will take longer to boot, but at least your session is saved. I wanted to figure out how to do this on Linux (Fedora), and I was surprised to find out that SystemD already supports this.
Per the documentation, I attempted to edit
/etc/systemd/sleep.conf. I changed
suspend-then-hibernate however this appeared to break GNOME’s suspend. Closing the laptop lid did nothing, and then in the power setting suspend was completely gone.
I found out that this feature has been kicking around for a while, however its been debated if it should be used or not.
I was just looking for a simple solution, I don’t really want to modify how my distribution handles suspending. Luckily I found a simple solution, using
/etc/systemd/system directory to override the default behavior.
sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
systemd-suspend-then-hibernate service already exists, creating a symlink to
/etc/systemd/system/systemd-suspend.service causes the default SystemD service to be overridden.
Since nothing was actually edited, I’m only referencing (symlinking) system files, I figure this method should survive an upgrade unless something fundamental changes.
At this point, the only thing changing in
HibernateDelaySec= which I set to 30min. All other settings should be left commented out. After testing, it works perfectly.