[systemd-devel] Boot ordering

Christoph Pleger Christoph.Pleger at cs.tu-dortmund.de
Wed Mar 18 09:10:11 PDT 2015


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.

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



More information about the systemd-devel mailing list