Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-13 Thread Matt Schuckmann
Umut,

That works, it took me a little while to get the details worked out because 
there are few resources that are unavailable when the generators run.


Thank you,

Matt S.


Message: 1
Date: Tue, 12 Feb 2019 13:49:48 +0100
From: Umut Tezduyar Lindskog 
To: Matt Schuckmann 
Cc: "systemd-devel@lists.freedesktop.org"

Subject: Re: [systemd-devel] Starting services enabled by filesystem
overlay over /etc/
Message-ID:

Content-Type: text/plain; charset="UTF-8"

> Also checkout systemd generators
> (https://www.freedesktop.org/software/systemd/man/systemd.generator.html<https://www.freedesktop.org/software/systemd/man/systemd.generator.html>).
> A generator can overlay the /etc and generators should run before
> systemd starts scanning the unit files.

> Umut

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-12 Thread Umut Tezduyar Lindskog
Also checkout systemd generators
(https://www.freedesktop.org/software/systemd/man/systemd.generator.html).
A generator can overlay the /etc and generators should run before
systemd starts scanning the unit files.

Umut

On Mon, Feb 11, 2019 at 10:07 PM Matt Schuckmann
 wrote:
>
> Thank you all for the responses.
>
> It sounds like I should look into creating an initramfs to mount my writable 
> partitions and /etc overlay. I've never created an initramfs so it might take 
> me a bit to work through it.
>
>
> In the mean time I've found that masking services does work with my overlay 
> for enabling or disabling services. So my plan now is to leave the service 
> enabled in the read-only rootfs and then mask or unmask it in the /etc 
> overlay.  This seems to be a reasonable workaround until I can get an 
> initramfs in place; unless one of you helpful people tells me otherwise.
>
>
> Thanks,
>
> Matt S.
>
>
> [PS I hope this gets added to the correct thread, I'm only receiving digests 
> and I'm not sure how best to respond].
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-11 Thread Matt Schuckmann
Thank you all for the responses.

It sounds like I should look into creating an initramfs to mount my writable 
partitions and /etc overlay. I've never created an initramfs so it might take 
me a bit to work through it.


In the mean time I've found that masking services does work with my overlay for 
enabling or disabling services. So my plan now is to leave the service enabled 
in the read-only rootfs and then mask or unmask it in the /etc overlay.  This 
seems to be a reasonable workaround until I can get an initramfs in place; 
unless one of you helpful people tells me otherwise.


Thanks,

Matt S.


[PS I hope this gets added to the correct thread, I'm only receiving digests 
and I'm not sure how best to respond].
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-11 Thread Lennart Poettering
On So, 10.02.19 17:28, Mantas Mikulėnas (graw...@gmail.com) wrote:

> On Sun, Feb 10, 2019 at 10:07 AM Andrei Borzenkov 
> wrote:
>
> > 09.02.2019 21:45, Matt Schuckmann пишет:
> > >
> > > What do I need to do to get systemd to automatically start the services
> > that are marked enabled in that overlay?
> > >
> >
> > I am not aware of any clean way to do it. Attempting to re-queue start
> > of default.target will likely be noop as this request is already queued.
> >
> > The only workaround I can think of is to make initial boot into target
> > that mounts overlay and then triggers start of actual default target.
> >
>
> In other words, do it from an initramfs.

Yes, this is the way to go.

In context of this: we hopefully will merge this soon:

https://github.com/systemd/systemd/pull/11243

If it is merged systemd can set up the overlayfs for the root fs
automatically for you in the initrd, without any manual scripting.

Lennart

--
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-11 Thread Jonathon Kowalski
On Sunday, February 10, 2019, Andrei Borzenkov  wrote:

> 09.02.2019 21:45, Matt Schuckmann пишет:
> > I have an embedded system with a readonly rootfs.
> >
> > I've setup a very early service that mounts a writable aufs overlay over
> /etc/.
> >
> >
> > The problem I'm having is systemd is not starting any services that I
> have enabled in that overlay that were not initially enabled in the
> readonly rootfs.
> >
> > ?I've tried placing a calls to systemctl daemon-reload or systemctl
> daemon-reexec just after mounting the overlay but the services are not
> started, after the fact systemctl will report that the services are enabled
> but inactive.
> >
>
> If you are doing it as part of normal startup, then systemd has already
> computed initial "transaction". While daemon-reload makes it rescan for
> and see additional unit definitions, it does not change currently
> running "transaction".
>
> >
> > What do I need to do to get systemd to automatically start the services
> that are marked enabled in that overlay?
> >
>
> I am not aware of any clean way to do it. Attempting to re-queue start
> of default.target will likely be noop as this request is already queued.


Unless I am misunderstanding something (in the code), it wouldn't be a
noop. After the reload/reexec, systemd should have updated the
Wants=/Requires= property of target. Now, the transaction that was
activated previously will not change based on this (because it was computed
in the past, checked for consistency, minimised for impact, jobs
merged/collapsed and then activated). At this point, there isn't even a
transaction, it's just a set of jobs installed on units waiting on each
other in run queue.

However, systemd, if you happen to trigger a start job on default.target
replacing the installed job now, will compute a transaction again, and
trigger jobs for everything again. Since this is all across transactions,
this will result in another transaction being applied, duplicate jobs
produced in both getting merged in installed one, but also the enabled
units starting up, with new jobs installed for those.

So invoking a 'systemctl start default.target --job-mode replace' again
will make the enabled units start up.

However, this has one disadvantage: You may end up having start jobs
triggered for already started->inactive units again (think oneshots)
(because there jobs slots are free after it finishing, so nothing to
coalesce, hence a trigger again). For running units, state change is noop
so it installs and finishes immediately. Where this can be surprising is
later activation triggers a stop job for some unit enabled on boot (through
Conflicts=, PartOf=), and then you end up trigger a start for it again,
producing incorrect results.

Still, all this said, it would be more correct to do it from initramfs as
grawity suggests, and then have all of this computed as part of initial
transaction at boot.

>
> The only workaround I can think of is to make initial boot into target
> that mounts overlay and then triggers start of actual default target.
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-10 Thread Mantas Mikulėnas
On Sun, Feb 10, 2019 at 10:07 AM Andrei Borzenkov 
wrote:

> 09.02.2019 21:45, Matt Schuckmann пишет:
> >
> > What do I need to do to get systemd to automatically start the services
> that are marked enabled in that overlay?
> >
>
> I am not aware of any clean way to do it. Attempting to re-queue start
> of default.target will likely be noop as this request is already queued.
>
> The only workaround I can think of is to make initial boot into target
> that mounts overlay and then triggers start of actual default target.
>

In other words, do it from an initramfs.

-- 
Mantas Mikulėnas
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-10 Thread Andrei Borzenkov
09.02.2019 21:45, Matt Schuckmann пишет:
> I have an embedded system with a readonly rootfs.
> 
> I've setup a very early service that mounts a writable aufs overlay over 
> /etc/.
> 
> 
> The problem I'm having is systemd is not starting any services that I have 
> enabled in that overlay that were not initially enabled in the readonly 
> rootfs.
> 
> ?I've tried placing a calls to systemctl daemon-reload or systemctl 
> daemon-reexec just after mounting the overlay but the services are not 
> started, after the fact systemctl will report that the services are enabled 
> but inactive.
> 

If you are doing it as part of normal startup, then systemd has already
computed initial "transaction". While daemon-reload makes it rescan for
and see additional unit definitions, it does not change currently
running "transaction".

> 
> What do I need to do to get systemd to automatically start the services that 
> are marked enabled in that overlay?
> 

I am not aware of any clean way to do it. Attempting to re-queue start
of default.target will likely be noop as this request is already queued.

The only workaround I can think of is to make initial boot into target
that mounts overlay and then triggers start of actual default target.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Starting services enabled by filesystem overlay over /etc/

2019-02-09 Thread Matt Schuckmann
I have an embedded system with a readonly rootfs.

I've setup a very early service that mounts a writable aufs overlay over /etc/.


The problem I'm having is systemd is not starting any services that I have 
enabled in that overlay that were not initially enabled in the readonly rootfs.

?I've tried placing a calls to systemctl daemon-reload or systemctl 
daemon-reexec just after mounting the overlay but the services are not started, 
after the fact systemctl will report that the services are enabled but inactive.


What do I need to do to get systemd to automatically start the services that 
are marked enabled in that overlay?


Matt S.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel