Delayed hibernation on Linux with SystemD

One thing that I liked on modern laptops with MS Windows or Apple macos was this power saving technique od delayed hibernation. On set timeout of inactivity or after closing laptop’s lid it goes into suspend and then after sometime into hibernation. That’s great because it stops battery drainage needed to support RAM during regular suspend. With it I can go for days of work without the need to recharge my laptop. From many methods to achieve this with SystemD this one worked always and keeps working for me to this day.

But first things first. You need to check if your machine is capable of hibernation. Generally you need to have a swap partition at least a little bigger then your RAM capacity. My machine is also encrypted with LUKS so my kernel line has the following line included:


While adding it to your bootloader config make sure that you account for your distro specific variables like different name of swap partition in LVM config (you can check it by listing /dev/mapper/). Additionally my mounting of swap partition in /etc/fstab goes like this:

UUID=r5f026te-e9d2-4973-81fd-998e04dae75f    none    swap    defaults    0 0

After your swap is properly setup you can go ahead and check if hibernation works by executing:

sudo systemctl hibernate

If your laptop went dark after a minute or so and resumed after you pushed the power button you’re good to go. Now it’s time for the actual delayed hibernation setup.

Backups, backups, backups. To stay on the safe side if you have file /etc/systemd/system/systemd-suspend.service present, make a copy:

sudo cp /etc/systemd/system/systemd-suspend.service /etc/systemd/system/systemd-suspend.service.orgi

Then we do the actual change to replace original suspend action with our desired one:

sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service

And that’s mostly it. Now we can adjust the timeout after which our machine will go from suspend to hibernation. This one takes some experimentation. For me optimal value is 15 minutes. If I didn’t open my laptop after that time I’m probably out commuting to another location or done fo the day. To make the adjustment we edit /etc/systemd/sleep.conf, uncomment the following line and set the time:


Now any suspend action called by you or any kind of automation will trigger delayed hibernation.

Please note that in different distros documentation you can find many other tutorials and ways to set this up. Most of them is outdated. The one presented above while being the oldest one, is working for me at any point of time and in any GNU/Linux distribution with SystemD.

When you’ll find that you lack some of the files or some other differences please follow this thread on mastodon and feel free to contact me.

For example on Ubuntu you might find service file that you need to symlink under:

Continue Reading

Canonical is doing it wrong. Again.

Looks like Canonical, creators of Ubuntu had a great idea to implement new multi-device Linux distro – one code base for all, but development takes too long. Results?

  • Desktop users left with almost nothing to be happy about in each release for some time now. Even package manager called “Software Center” isn’t working properly anymore for independent devs.
  • Mobile users can try to think positive about upcoming Ubuntu Phone releases, but they have to try really hard
  • Ubuntu will probably grow independent from Debian and deb packages, but not yet, so no new defaults in upcoming releases and no changes in present set of apps.
Continue Reading

Using OpenVPN with cheap VPS and NetworkManager

Another gathering of information laying around in various places over the web. This time I wanted to configure OpenVPN on cheap VPS (OVH classic) and my Linux laptops and Android devices. After great deal of problem solving here it is:

The easy part is installing OpenVPN on your VPS. Just follow the guide from DigitalOcean. Download your desired file (I use autologin version). It’s written for CentOS but works well on other distros too. In my case on Ubuntu Server.

Continue Reading

Pidgin as default IM client in GNOME 3

Empathy is a good IM client. It’s pushed as a default one in Ubuntu, its remixes and all other distros using GNOME environment. It has one big lack, witch makes it really bad choice for your default one. Off-the-Record messaging (OTR) is somethin’ that any modern IM client should support. You can find it in Kopete from KDE, even Adium on Mac OS X has it… Where is this support in GNOME? Nowhere… There is a bug reported in 2008 and yet it’s still not implemented.

So how can we change the default IM client in GNOME 3 and still get this eye candy and handy support? There are two choices (but of course you can use also QT based clients like Kopete or PSI if you want): Gajim (supporting OTR since 0.15) and Pidgin. I’ve chosen second one (you should too if you want to connect with users of other networks than xmpp).

Continue Reading