Repository navigation
systemd: Add bootc-log-boot.service to journal the booted image - #2681
Merged
Merged
Conversation
Johan-Liebert1
requested changes
Nov 24, 2026
Johan-Liebert1
left a comment
Member
There was a problem hiding this comment.
Thanks for working on this!
Prep for logging the booted image at boot without going through `bootc status`. On composefs that path remounts `/sysroot` read-write, mounts the ESP and may migrate boot entries. The new caller only needs the image metadata of the booted deployment, which this function builds from the origin file and the composefs repository. No behavior change intended. Generated-by: AI Signed-off-by: Franck Cuny <[email protected]>
On systems that are installed once and never updated, nothing records which image the system booted: nothing is ever staged, and `bootc install` logs to the installer's journal, not the target's. Write one structured journal entry on every boot, so the journal always holds a recent record whatever its retention. The first boot of a deployment is the oldest entry with its `BOOTC_DEPLOYMENT`. The generator enables the unit on native composefs boots only for now, and the unit carries a matching kernel command line condition. `bootc internals log-boot` opens the deployment state and the composefs repository read-only, through a new `Storage` constructor. Unlike the `bootc status` path, it doesn't remount `/sysroot`, mount the ESP or touch boot entries, so it needs no private mount namespace. The entry goes through libsystemd directly rather than `tracing`. The tracing journald layer prefixes custom fields with `F_`, so a `message_id` field would be stored as `F_MESSAGE_ID` and `journalctl MESSAGE_ID=...` would not match it. Related: bootc-dev#452 Generated-by: AI Signed-off-by: Franck Cuny <[email protected]>
fcuny
force-pushed
the
log-boot-journal
branch
from
November 24, 2026 14:34
30691e1 to
ccbb7a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On systems that are installed once and never updated, nothing records which image the system booted: nothing is ever staged, and
bootc installlogs to the installer's journal, not the target's. This addsbootc-log-boot.service, which writes one structured journal entry on every boot. It implements the proposal in #452 (comment), for the composefs backend only.The entry carries
BOOTC_BACKEND,BOOTC_DEPLOYMENT(the composefs verity digest),BOOTC_IMAGE,BOOTC_TRANSPORT,BOOTC_MANIFEST_DIGEST,BOOTC_ARCHITECTURE, andBOOTC_VERSIONandBOOTC_TIMESTAMPwhen the image has them. The first boot of a deployment is the oldest entry with itsBOOTC_DEPLOYMENT.bootc-log-boot.service(5)documents the fields.Two choices differ from what the issue comment suggested:
bootc statuspath. On composefs,BootedStorage::newmounts the ESP and runsprepend_custom_prefixon every invocation. A logging unit that runs unattended at every boot shouldn't do that, and a failure there would lose the audit record.log-bootreads only the deployment's origin file and the image in the composefs repository. The first commit is a prep refactor that letsget_imginfowork without a fullStorage. So the command is not backend-agnostic after all, and the ostree follow-up needs its own small reader.tracing. The tracing journald layer inbootc_utils::initialize_tracingkeeps tracing-journald's defaultFfield prefix. So every existingmessage_id = ...entry is stored asF_MESSAGE_ID, andjournalctl MESSAGE_ID=...doesn't match it (the tmt tests already queryF_MESSAGE_ID). This entry useslibsystemd::logging::journal_sendto get a realMESSAGE_ID. Fixing the layer would rename every existing field, so I left that for a separate issue.Out of scope: the ostree backend, and the finalize-time entry from the original issue.
Testing
cargo fmt --check,cargo test -p bootc-lib --lib(345 passed),cargo clippywith the CI lint config, andcargo doc -D warnings, on Fedora 43 aarch64.bootc-dev/actions/bootc-host-setup. The base was CentOS Stream 10, and SELinux was enforcing in both runs. Both runs passed all 26 readonly tests, including 014 (no failed units) and the new 056:just test-tmt-nobuild --filesystem=ext4 --seal-state=unsealed --boot-type=bls readonlypassed.just test-tmt readonlypassed. The unit isn't enabled there, and 056 finds no entry.Test 056 output from the composefs run:
The test also asserts that each field matches
bootc status --jsonand that the unit exited 0 during this boot. It passing with SELinux enforcing shows thatbootc_tcan read/sysroot/stateand/sysroot/composefsat boot without theinstall_ttransitionbootc statususes. I did not run the other composefs cells: grub, UKI, sealed, and btrfs/xfs.AI disclosure
Generated-by: AI
I don't have particular experience with Rust, so please review the Rust code with extra care. I reviewed the design and the behavior, and the tests above pass.
Related: #452