<div dir="ltr">I'm trying to understand some implications of the way systemd loads /etc/machine-id.<br><br>My understanding is, first: systemd reads /etc/machine-id during <i>early boot.</i> At that point, I'm only guaranteed that the <i>root</i> filesystem will be there for me.<div><br></div><div>Second: there's no way to delay that machine-id initialization until other filesystems are ready. It happens early, no matter what.</div><div><br></div><div>Therefore: if I want a persistent machine-id across reboots, and I want systemd to autogenerate it on first boot instead of me predefining it as part of installation, then my machine needs the ability to write to its own root filesystem.</div><div><br></div><div>For example, you couldn't have: (1) a permanently <i>read-only-</i>mounted root filesystem, to which /etc belongs; (2) a separate partition containing a writeable machine-id file, which gets bind-mounted atop /etc/machine-id. Because the writable one would be available too late in the boot process.<div><div><br></div><div>Is all of this correct?</div><div><br></div><div>For context, I'm working on an embedded-ish device. We prefer to keep our rootfs read-only. All of our writeable stuff, including some system-level config files, is in a separate filesystem, accessible from the rootfs by symlinks or bind mounts. To update the device's software, we replace the whole root partition. This is nice because we never have to worry about an update accidentally clobbering some piece of configuration that's meant to be persistent. Our problem is that, since our rootfs images have an empty /etc/machine-id, a new machine-id gets generated in memory each time the device reboots. </div></div></div><div><br></div><div>I'm aware of <a href="https://www.freedesktop.org/software/systemd/man/systemd-machine-id-commit.service.html" target="_blank">systemd-machine-id-commit.service</a>, but that seems to only work for <i>remounting the rootfs</i> as read-write, not using a different filesystem entirely. It would let me write-back the machine-id when that filesystem becomes writable, but it wouldn't let me postpone reading the machine-id until that filesystem is mounted. So systemd would still generate a new machine-id on each reboot, I think.</div></div>