Skip to content

Services with ConditionNeedsUpdate= are still executed at first boot #3338

Open
@septatrix

Description

@septatrix

mkosi commit the issue has been seen with

main

Used host distribution

Fedora 41

Used target distribution

Arch

Linux kernel version used

6.12.7-200.fc41.x86_64

CPU architectures issue was seen on

x86_64

Unexpected behaviour you saw

On the first boot services which have ConditionNeedsUpdate=/var (or /etc) set are still started even though they are fresh images. This delays the bootup unnecessarily. For images with an immutable /etc this might even result in them being started each boot (as the /etc/.updated file cannot be created) though I did not explicitly test that.

One example of such a service is systemd-journal-catalog-update even though the catalog is freshly installed. systemd-hwdb-update would be a similar candidate, however, it has additional checks which do not trigger because mkosi manually invokes systemd-hwdb --usr. For other services these optimizations do not exist.

mkosi should likely start all services which use ConditionNeedsUpdate= as part of the build process and call /usr/lib/systemd/systemd-update-done at the very end. Doing it this way should be safe as either: The /etc and/or /var directories are included in the image in which case their generated files would also be included, or, they are not included in which case the .updated files would also be absent resulting in them being invoked again as expected.


(I noticed there is also another issue if a device reboots from v1 to v2 after v3 is built but not yet installed. In that case the .updated files will have timestamps later than v3's /usr resulting in ConditionNeedsUpdate= not being triggered after a subsequent update from v2 to v3. This, however, is a technical problem in the way these .updated files currently work and not a problem of mkosi.)

Used mkosi config

Default config from this repo

mkosi output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions