On 20 Feb 2025, at 15:33, Vyacheslav Yurkov <uvv.m...@gmail.com> wrote: > Isn't is supposed to be created on first boot?
Yes, ish, but our rootfs is read only at this point: [ 7.639766] systemd[1]: System cannot boot: Missing /etc/machine-id and /etc is mounted read-only. [ 7.641135] systemd[1]: Booting up is supported only when: [ 7.641844] systemd[1]: 1) /etc/machine-id exists and is populated. [ 7.642588] systemd[1]: 2) /etc/machine-id exists and is empty. [ 7.643279] systemd[1]: 3) /etc/machine-id is missing and /etc is writable. On 20 Feb 2025, at 16:03, Alex Kiernan <alex.kier...@gmail.com> wrote: > I do know that it was a horrible thing to get right when I rewrote the > shell script in python (which I'm very glad to see the back of): > > # If we populate the systemd links we also create /etc/machine-id, which > # allows systemd to boot with the filesystem read-only before generating > # a real value and then committing it back. > # > # For the stateless configuration, where /etc is generated at runtime > # (for example on a tmpfs), this script shouldn't run at all and we > # allow systemd to completely populate /etc. > > It may be that this behaviour was wrong in some cases, but at the same > time, I remember spending a lot of time getting this right! It certainly looks like it’s “tricky” to get the right semantics here because the range of potential use-cases is too great. I believe we should be writing /etc/machine-id at rootfs time if systemd is being used. Currently this is done in the systemctl class if it writes links, and then in the rootfs class if the rootfs is read-only. I think we should consolidate those into the rootfs class, and give the user the choice of whether to treat the image as booted or not by writing either “” or “uninitialized” to the file as per https://www.freedesktop.org/software/systemd/man/latest/machine-id.html#First%20Boot%20Semantics. tl;dr: if it contains “uninitialized” then this is the first boot, otherwise it’s not. By always touching the file we break the ability for anyone to use systemd-first-boot or ConditionFirstBoot in their own units, which seems wrong. We’re about a week from feature freeze and getting this merged would be great, do you think you can finish this off Slava? Thanks, Ross
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#211908): https://lists.openembedded.org/g/openembedded-core/message/211908 Mute This Topic: https://lists.openembedded.org/mt/111267385/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-