[systemd-devel] Ordering for early initialization services

Lennart Poettering lennart at poettering.net
Fri Mar 22 19:55:50 PDT 2013


On Fri, 08.03.13 14:12, Umut Tezduyar (umut at tezduyar.com) wrote:

> Hi,
> 
> What would be the advantage of placing an early boot up script in between
> local-fs.target/sysinit.target OR in between
> sysinit.target/basic.target?

That's a very good question. This hopefully gives a bit of an explanation:

http://www.freedesktop.org/software/systemd/man/bootup.html

The difference is not that big actually. Basically, sysinit.target is
supposed to be the barrier before which all the OS vendor system
initialization stuff is finished. And then basic.target is the
barrier before normal user services are started. In between the two we
initialize the sockets currently, and only really those. i.e. units that
belong to the user, but should run before the actual services are
started.

I plan to introduce "paths.target" and "timers.target" in a similar
fashion soonishly. Also, as soon as we have kdbus support in systemd we
will do bus name registration the same way. I.e. there will be a new
unit type ".busname" for establishing bus names, and they by default are
established between sysinit.target and busnames.target or so.

Now, some of systemd's own services aren't entirely consistent between
what it puts before sysinit.target and what before basic.target. But
this is something we should clean up.

But in general the rule is: you should place your early-boot stuff
*before sysinit.target*. And your late-boot stuff *after
basic.target*. And leave everything in between for .socket, .path,
.timer, .busname units.

> I cannot decide what should be the ordering for some early initialization
> "oneshot" services I have in my embedded system. These services makes some
> simple preparations that were previously in /rcS.d/. Dropped support for
> /rcS.d/ in systemd was placing these services as After=sysinit.target and
> WantedBy=sysinit.target (and I am not entirely sure but possibly
> Before=basic.target). I could place them as systemd did before or I could
> place them as After=local-fs.target and Before=sysinit.target.
> 
> Since my embedded system doesn't have login prompt, I don't see the
> difference between basic.target and sysinit.target other than socket
> activation. Even then, a service that is socket activated has
> DefaultDependency=yes (It will start after basic.target).
> 
> To summarize, where are users encouraged to place their early boot up
> initialization services (ex: setting up the bandwith on a NIC)?

sysinit.target!

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list