[systemd-devel] Journalctl --list-boots problem

Martin Townsend mtownsend1973 at gmail.com
Thu Oct 31 20:39:09 UTC 2019


On Thu, Oct 31, 2019 at 4:34 PM Lennart Poettering <lennart at poettering.net>
wrote:

> On Di, 08.10.19 16:57, Martin Townsend (mtownsend1973 at gmail.com) wrote:
>
> > Thanks for your help.  In the end I just created a symlink from
> > /etc/machine-id to /data/etc/machine-id.  It complains really early on
> > boot with
> > Cannot open /etc/machine-id: No such file or directory
> >
> > So I guess it's trying to read /etc/machine-id for something before
> > fstab has been processed and the data partition is ready.
> >
> > But the journal seems to be working ok and --list-boots is fine.  The
> > initramfs would definitely be more elegant solution to ensure
> > /etc/machine-id is ready.
> >
> > I don't suppose you know what requires /etc/machine-id so early in the
> boot?
>
> PID 1 does.
>
> You have to have a valid /etc/machine-id really, everything else is
> not supported. And it needs to be available when PID 1 initializes.
>
> You basically have three options:
>
> 1. Make it read-only at boot, initialize persistently on OS install
>
> 2. Make it read-only, initialize it to an empty file on OS install, in
>    which case systemd (i.e. PID 1) overmounts it with a random one
>    during early boot. In this mode the system will come up with a new
>    identity on each boot, and thus journal files from previous boots
>    will be considered to belong to different systems.
>
> 2b. (Same as 2, but mount / writable during later boot, at which time
>     the machine ID is commited to disk automatically)
>
> 3. Make it writable during early boot, and initialize it originally to
>    an empty file. In this case PID 1 will generate a random one and
>    persist it to disk right away.
>
> Also see:
>
> https://www.freedesktop.org/software/systemd/man/machine-id.html
>
> Lennart
>
> --
> Lennart Poettering, Berlin
>

Hi Lennart,

Thank you for the information it was very useful.  Reading the link on
machine-id gives my another option and that is to pass the machine-id via
U-Boot to the kernel via its bootargs.  As some background this is for an
embedded system that is using systemd and Mender which seems to becoming
fairly popular so hopefully this may help someone else who stumbles across
this post with the same problem.  Mender provides image updates on an A/B
root filesystem, so having /etc/machine-id within the root filesystem isn't
really feasible but with Mender you get a persistent data partition that
both root filesystems share, hence why have opted for a symlink to the
persistent partition. So for embedded systems using Mender that want a
persistent machine-id I see two options now:

1) Use an initramdisk to mount the persistent mender data partition and
store machine-id in here with /etc/machine-id a symlink
2) and thanks to your link I think we could store the machine-id in the
U-Boot environment and pass it in as the systemd.machine_id= kernel command
line parameter.

Out of interest what does PID 1 need /etc/machine-id for before it has
processed fstab (and hence the persistent data partition would be ready to
read the /etc/machine-id symlink)?  We haven't implemented either of the
above so I wouldn't mind knowing what the impact would be.

Cheers,
Martin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20191031/a994fcfc/attachment.html>


More information about the systemd-devel mailing list