[systemd-devel] howto migrate some things to systemd

Lennart Poettering lennart at poettering.net
Tue Apr 19 16:21:06 PDT 2011


On Sun, 17.04.11 10:33, Michael Olbrich (m.olbrich at pengutronix.de) wrote:

> Hi,
> 
> I'm trying to migrate some stuff to systemd, but I have some problems
> getting it right.
> The scenario:
> I'm cross-building root file systems. I try to do as much as possible
> on the host system, but there is some stuff that needs to run on the target
> when booting for the first time. I'm not sure how to integrate this with
> systemd.
> Some of the issues I have:
> - With a classic init, the init-script just touches a file to indicate the
>   one-time stuff is complete. Is there a better way for this with
>   systemd?

You could do this too, and then use ConditionFileExists=/flagfile to
suppress execution of the service. 

If this is for SSH keys and stuff you might even want to split this up
into several units and just look for the sshd key files
directly. i.e. stick in your ssh-keygen.service something like this:

ConditionFileExists=!/etc/ssh/ssh_host_rsa_key

That way are things are nice and robust. And it comes at the cost of an
access() syscall. Which I think is pretty cheap.

> - The system usually runs with a read-only mounted rootfs. I remount it
>   temporarily for the one-time stuff. However this confuses other services
>   that run at the same time.
>   I'm not sure what's the best solution for this.

Maybe just add ordering deps relative to those confused services? That
way you could ensure that the disk is mounted read-only again before
they are invoked?

> - One of the task is prelinking the whole system. This means all programs
>   and libraries are modified, so nothing else should be running. And
>   systemd must be restarted before the rootfs can be mounted read-only.
>   Again I have no idea how to do this.

Best place is probably to stick this between sysinit.target and
basic.target, where there is very little else running.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list