[systemd-devel] Read-only /etc, machine-id with an overlay - journald failing

Lennart Poettering lennart at poettering.net
Tue Mar 31 13:52:44 UTC 2020


On Mi, 26.02.20 09:44, Andreas Kempe (andreas.kempe at actia.se) wrote:

> Hello everyone,
>
> I'm working in a project with an embedded Linux system based on
> Openembedded using Systemd version 241 as our init process. We're
> using a read-only /etc. To facilitate development, we want to use a
> writeable overlay on /etc, but we ran into an issue.
>
> When we start, Systemd detects that there is no machine-id file
> present in /etc so it generates and mounts a /etc/machine-id. When our
> mount unit then applies the overlay on /etc, it hides the mounted
> file. Journald later fails to start because /etc/machine-id isn't
> visible through the overlay.

So when you swap out /etc you really should so so atomically, and
ensure that at no point in time stuff (i.e. mounts) go missing while
you shift things around. In particular not the machine-id.

Hence, the code that replaces /etc with an overlayfs, why doesn't it
bind mount /etc/machine-id into the new overlayfs before moving it
into place? i.e. first mount the overlayfs to some tmpdir, bind mount
/etc/machine-id into it, then use mount --move to move the fully
prepped overlayfs along with all submounts to /etc. That way noone
will notice anything changing.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list