[systemd-devel] Implementing resume from hibernation as a systemd unit file

Lennart Poettering lennart at poettering.net
Wed Aug 13 18:10:30 PDT 2014

On Mon, 28.07.14 14:06, Ivan Shapovalov (intelfx100 at gmail.com) wrote:

> Hello all,
> I'm trying to implement resuming from hibernation with systemd-based initramfs,
> i. e. in terms of systemd unit files. That is, there should be a unit which
> waits for the resume device and writes its major:minor into /sys/power/resume.
> I've chosen to write a templated resume@<path>.service and a generator which
> parses 'resume=' kernel parameter and enables a corresponding instance of the
> resume at .service unit.
> The resume at .service itself shall be ordered so that it is activated when there
> are no filesystems mounted read-write, except tmpfs instances. It will be good
> if it works both from initramfs and from real rootfs (if it is mounted RO).
> So, here are some questions:
> - is it the way to go (overall)?
> - is it OK to use generators for outlined purpose?
> - how to order resume at .service and where to symlink it?
> I'm using Arch, if that matters -- but, IIUC, Arch strives to do everything
> "in the upstream's way", so there should be no distro-specific details.

I am not entirely sure how the hibernation logic precisely works, but
wouldn't it be possible to write a little udev rule (maybe with a
helper) that adds a special device node symlink to the resume partition,
so that /dev/disk/resume or so always points to the resume partition to

That udev rule should then maybe also pull in a unit that acts on
it. But that unit doesn't have to be an instance, could just be a normal

Does that make any sense?


Lennart Poettering, Red Hat

More information about the systemd-devel mailing list