[systemd-devel] starting a service before anything else....

Lennart Poettering lennart at poettering.net
Thu Jun 28 16:15:47 UTC 2018


On Do, 28.06.18 16:55, MALET Jean-Luc (jeanluc.malet.snowsat at gmail.com) wrote:

> [Unit]
> Description=mount some file systems before anything and prepare the system
> Before=systemd-remount-fs.service
> 
> [Service]
> Type=oneshot
> ExecStart=/etc/init.d/setup.sh start
> 
> [Install]
> WantedBy=swap.target

Unless this tool has anything to do with swap management, it shouldn't
hook into swap.target.

Early boot services are usually pulled in by sysinit.target,
i.e. you want WantedBy=sysinit.target.

A concept of "before everything" doesn't exist in systemd, because
it's conceptually a major source of problems (i mean, what do you do
if you have multiple services that want to run before everything?).

If your service is related to mounts, and you want to make sure you
run before all mounts that haven't explicitly turned off default
dependencies, then order yourself before "local-fs-pre.target" and
pull it in with Wants=. You can achieve something similar by ordering
yourself before systemd-remount-fs.service as that aleady carries
those deps, and hence you transitively gain the same ordering deps if
you order yourself before it.

Note that all early boot stuff needs to set DefaultDependencies=no as
otherwise it will automatically be place in the late boot phase.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list