Need help with converting growroot to a systemd service

Lennart Poettering mzerqung at 0pointer.de
Mon Aug 11 13:24:59 UTC 2014


On Mon, 11.08.14 12:59, Juerg Haefliger (juergh at gmail.com) wrote:

> All,
> 
> I want to convert the growroot functionality to a proper systemd service

Not sure what "growroot" is...

> but I'm struggling. I (think I) want it to run and finish before the
> filesystems are checked and before /sysroot is mounted. 

This is supposed to be an initrd service hence?

> For testing purposes, I replaced the growroot script with a simple
> script that sleeps for 5 seconds and emits debug messages at the
> beginning and at the end.  What I end up with is that fsck is started
> before growroot and I can't seem
> to figure out why that is. What I have at the moment is:

fsck units are ordered after the devices they are supposed to check, and
before the mount units for it. If you want your service to run before
the fsck, you'd have to order your service between the device and the fsck.

> 
> [Unit]
> Description=Grow the root partition
> After=systemd-readahead-collect.service systemd-readahead-replay.service
> Before=systemd-fsck at .service sysroot.mount

This will not work. "systemd-fsck at .service" is is not a unit name (but
just a template for unit names), and dependencies may only be declared
relative to other units, never to templates. (I admit though that this
might be useful to have, but then again, I am not sure how we could
implement this nicely...).

My recommendation would be to add a dropin file
systemd-fsck at .service/foobar.conf or so, which adds the reverse
dependency of the one you are looking for. Or in other words: extend the
systemd-fsck at .service definition, instead of your growroot.service definition.

> 
> [Service]
> Type=oneshot
> ExecStart=/bin/growroot
> StandardOutput=syslog+console
> StandardError=syslog+console

These two are unnecessary, as all services stdout/stderr will be
connected to the journal anyway by default, and "syslog" and "journal"
in this context are pretty much identical (in fact, we should probably
remove any reference to syslog in the docs, to avoid the confusion...)

> Also, I suspect I need to add this service to a target unit. What would be
> the most appropriate one? Currently it's initrd.target.

This sounds appropriate for an initrd service.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the devel mailing list