[systemd-devel] Journalctl reading incorrect file
John Lane
systemd at jelmail.com
Fri Jan 29 11:34:04 UTC 2021
>
> Is it possible you are playing some weird games with your machine ID
> or boot ID?
>
Maybe. Yes. I have a oneshot service that writes /etc/machine-id using
constant hardware-based info. But I've been using that for over two
years without any issues.
I did notice this when trying to investigate machine and boot ids:
$ # systemd-id128 machine-id
Failed to get machine-ID: Invalid argument
whereas on my other machines this returns the expected value.
So I looked at the source for systemd-id128, eventually in
./libsystemd/sd-id128/id128-util.c I discovered that the machine id
value is parsed and must contain enough digits for a uuid with/without
the hyphens. I know... as `man machine-id` says ;)
My oneshot service uses enough of
/sys/devices/virtual/dmi/id/board_serial to set a 32-character
hexadecimal lowercase machine id. On my other machines this returned
enough data to form a 32-character id but it didn't on the new one, so
the machine id had insufficient characters in it. I modified that
service to ensure the machine id has the required number of characters.
Problem solved!
Thanks for the pointer which helped me locate and resolve my issue.
The reason for settting machine id to a predictable value is because of
a need to refer to it in scripts etc meant it needed to be known
up-front, before the first install, but be somehow tied to the machine's
hardware. So that's what we did.
As an aside... Changing the machine id after the machine has booted,
like my oneshot service does, doesn't affect the current journal. Either
a restart of the journal or a reboot is required. This isn't a massive
problem as, after that first boot, the machine id is already in
/etc/machine-id and doesn't actually change.
But I'd like to do it properly so it works on the first boot also... is
there a pointer to the correct way to use a script to set the machine id
during boot?
More information about the systemd-devel
mailing list