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

Lennart Poettering lennart at poettering.net
Thu Aug 14 03:56:10 PDT 2014


On Thu, 14.08.14 09:20, Ivan Shapovalov (intelfx100 at gmail.com) wrote:

> The udev rule should be possible (provided that udevd does not need rootfs
> remounted read-write -- I'd like to preserve some decency towards initrd-less
> systems), but udev is a framework for handling events, whereas we don't have
> any events here: such symlink can be derived from kernel command-line alone,
> statically.

udev is totally fine with read-only everything. It just needs writable
/run.

> Yes, a udev rule would allow to create a symlink which is tracked by systemd,
> so the dev-disk-resume.device appears and then it can be easily After='ed
> from the resume unit, but... really, is udev the proper tool for this?

The symlink thing we already do in a very similar way for the gpt auto root logic (see
60-persistent-storage.rules) already, so there's prior art.

> Actually, the main question is how to order the resume unit. It needs to run
> before any real filesystems are mounted (speaking in terms of initrd) AND before
> rootfs is remounted read-write (speaking in terms of initrd-less system), but
> after whatever is needed to make the device node appear.

You could turn this into a generator, that pulls the switch from the
kernel cmdline, and generates a service that orders itself before
local-fs-pre.taret and after the device you need. The device you need
you give a stable name via an udev rule. 

That's pretty much exactly how the got auto root thing works...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list