[systemd-devel] Boot ordering

Andrei Borzenkov arvidjaar at gmail.com
Wed Mar 18 09:50:22 PDT 2015

В Wed, 18 Mar 2015 17:10:11 +0100
"Christoph Pleger" <Christoph.Pleger at cs.tu-dortmund.de> пишет:

> Hello,
> I am experimenting a little with systemd and trying to define a new
> "intermediate" runlevel, a runlevel between basic.target and
> multi-user.target. This means that I want the services which are required
> by my new runlevel to be started after all services from basic.target have
> been started and to be finished before any service from multi-user.target
> is started.

There is no feasible way to do it right now. In special cases it was
worked around by adding second target (local-fs.target =>
local-fs-pre.target) and explicitly ordering units after it.

Unfortunately it is not clear how to compute such dependency
automatically. So effectively if you want to insert some target you
need to order *all* units after it (or it before all units). Which does
not scale ...

> So far, I created /lib/systemd/test.target with
> [Unit]
> Description=Test target
> Requires=basic.target
> Conflicts=rescue.service rescue.target
> Before=multi-user.target
> After=basic.target rescue.service rescue.target
> and /lib/systemd/test.service with
> [Unit]
> Description=Test service
> [Service]
> Type=oneshot
> ExecStart=/usr/local/bin/test
> [Install]
> RequiredBy=test.target
> /usr/local/bin/test is a simple script which just echoes some words on the
> display and then sleeps for some minutes.
> In /lib/systemd/system/multi-user.target, in lines "Requires=" and
> "After=", I replaced basic.target with test.target .
> Then I called 'systemctl enable linf.service' and rebooted. The result was
> that the computer booted up to the graphical login screen much before the
> time I had put in the sleep command of my test script. I logged in from a
> remote machine by ssh and used ps to find out if there was a running sleep
> command from my script, and there was. So, obviously my script was
> executed during the boot phase, but not in the intended order after
> basic.target and before multi-user.target.
> Why does systemd not follow the above instructions to start the services
> of test.target after those of basic.target and before those of
> multi-user.target?
> Regards
>   Christoph
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel

More information about the systemd-devel mailing list