[systemd-devel] How to add a unit path to systemd?
Lennart Poettering
lennart at poettering.net
Mon Sep 10 17:20:50 UTC 2018
On Fr, 10.08.18 10:31, Filipe Brandenburger (filbranden at google.com) wrote:
> Hi Lennart,
>
> On Fri, Aug 10, 2018 at 3:30 AM Lennart Poettering
> <lennart at poettering.net> wrote:
> > On Do, 09.08.18 10:20, Daniel Wang (wonderfly at google.com) wrote:
> > > I want to append to systemd's unit search path a directory on my OEM
> > > partition, which is mounted by a .mount unit, at /usr/share/. I will be
> > > putting unit files in that partition, some of which I want to run before
> > > default.target. Is it possible to do so without a systemctl
> > > daemon-reload?
> >
> > /usr/share appears like a surprising place for this…
> >
> > In general, in systemd the assumption is that unit files are available
> > during earliest boot, so that the initial transaction can be
> > calculated with all units taken into account. Hence a relatively clean
> > solution might be to mount your partition already in the initrd, so
> > that systemd sees it in place already.
> >
> > Alternatively, you actually can issue daemon reload during the boot
> > process, but you'd have to enqueue the new units appearing explicitly,
> > i.e. trigger a second transaction because what isn't there won't be
> > considered in the initial one.
>
> I was pointing Daniel at the /usr/share/factory support in tmpfiles,
> which will populate a system with /var and /etc and I believe that
> includes enabling units and applying presets.
No, that's not correct. Units are enabled via presets from PID 1
during earliest boot, before we start looking for unit files to
load. The factory stuff is copied as part of systemd-tmpfiles.service,
i.e. much later during boot (though still in the "early" boot phase,
i.e. before basic.target has been reached). This means most regular
configuration files can be installed via factory, but the ones PID 1
needs itself can't, and that includes unit files.
> How do things work in that case? Is there an implicit daemon-reload
> that happens once /etc is populated from /usr/share/factory/etc?
It doesn't. Unit files can't be installed via the factory logic.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list