[systemd-devel] no installed machine-id vs systemd-in-initramfs

Lennart Poettering lennart at poettering.net
Thu Jul 11 16:04:18 PDT 2013

On Wed, 10.07.13 11:26, Colin Walters (walters at verbum.org) wrote:

> The gnome-ostree build system generates disk images that can be
> downloaded directly; there is no installer.
> In the old model of "dracut shell script + systemd", systemd's main.c
> has:
> if (arg_running_as == SYSTEMD_SYSTEM ...) {
>   ...
>   machine_id_setup();
>   ...
> }

machine_id_setup() will:

a) do nothing if /etc/machine-id is already valid

b) if it doesn't exist or is empty and the disk is writable, it will
   create a new randomized one

c) if it exists but is empty and the disk is read-only it will mount the
   file over with a randomized one from /run.

d) otherwise it will whine.

> So after mounting the rootfs, we'd end up writing one to /etc (at least
> in gnome-ostree which comes with a writable copy of /etc), and it would
> persist across reboots, and all would be well with the world.
> In the new systemd-in-initramfs model, journald is now launched in the
> initramfs.  Dracut will copy the host's machine id into the initramfs
> if it exists, but in the gnome-ostree case (or more generally
> "pre-canned OS" case), there isn't one.  journald will attempt to start,
> and fail.

I am pretty sure you should make use of c), i.e. create an empty stub
file in your initrd image and let systemd do its thing.

> One thought I had is to say:  If there's no /etc/machine-id in the
> initramfs, write one to /run/machine-id.  After mounting the rootfs,
> persist that to /etc.

there's no need to use the same one really. It's good to use the same,
but we are OK if they aren't, after all they are sufficiently distinct
systems with a different file system tree and so on.


Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list