Discussion:
[systemd-devel] /etc overlay
Barbier, Renaud
2021-05-28 16:31:56 UTC
Permalink
Hello,
We would like to have a ROFS volume on which the whole fs is and writeable config volume on which with have the same /etc.
Current kernel is 5.11
I have done an /etc/ overlay using the service var-volatile-etc for the RO FS. And then added another service to either mount the config /etc on top of the /etc overlay when the config volume is rw or mount the config volume to a temp directory and then overlay it to the /etc/ overlay when the volume is RO.

It seems to be working as I am able to disable our services (bit, sensor) on config volume and they don't start.
Also the OOB address is assigned from the configuration file.

Then I found https://lists.freedesktop.org/archives/systemd-devel/2019-February/042151.html further below in quote:

So is it my understanding that as long as the mount or overlay happen early enough which is around the service for var-volatile-etc then there is a rescan and all config from the /etc in the volume will be used then?

Following the thread, I also saw that it is advised to use initramfs. I am not clear why that makes a difference. This thread being 2 year old there may thing I am not aware of.
Cheers.


"> 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"."

Cheers,
Renaud
Lennart Poettering
2021-05-31 16:16:47 UTC
Permalink
Post by Barbier, Renaud
So is it my understanding that as long as the mount or overlay
happen early enough which is around the service for var-volatile-etc
then there is a rescan and all config from the /etc in the volume
will be used then?
The clean codepaths in systemd mean that systemd loads unit files
comprehensively only during early boot before it runs the first
services, or if something invokes "systemctl daemon-reload". The
latter is a bit dirty though, and won't change the boot transaction
already being executed at that time.

Thus, if you intend to drop in additional files as services you should
ideally do so before PID 1 initializes, i.e. in the initrd.

Lennart

--
Lennart Poettering, Berlin

Loading...