Skip to content

composefs: Keep the boot entries' os_id on rollback - #2631

Merged
Johan-Liebert1 merged 1 commit into
bootc-dev:mainfrom
krissedout:composefs-rollback-entry-names
Nov 10, 2026
Merged

Johan-Liebert1 merged 1 commit into
bootc-dev:mainfrom
krissedout:composefs-rollback-entry-names

Conversation

@krissedout

Copy link
Copy Markdown
Contributor

After bootc rollback, both boot entries are renamed: bootc_fedora-45-1.conf with sort key bootc-fedora-0 comes back as bootc_bootc-45-1.conf with sort key bootc-bootc-0. Every install, upgrade and switch writes the distro's name, so the names change depending on whether the last operation was a rollback, and since the sort keys change too the entries can move relative to anything else in the boot menu, such as another OS's entries on the same ESP. They stay that way until the next upgrade rewrites them. The bootc_bootc entries in the table in #2224 look like this as well.

rollback_composefs_entries() hardcoded "bootc" as the os_id, with a TODO to get the real one. The entries already have it, so this reads it from their sort keys and a rollback only swaps which one comes first. An entry with a sort key bootc didn't write still falls back to "bootc", so nothing changes for those.

On this branch cargo fmt --check, cargo check --workspace --all-targets, cargo test -p bootc-lib -p bootc-internal-blockdev and just validate pass, including a table-driven test for reading the os_id out of a sort key. test-rollback now also checks on systemd-boot that the entries keep their name and sort keys across bootc rollback.

I ran test-rollback with an image from just build on fedora-bootc:45 (composefs, systemd-boot, unsealed UKI, ext4), with SELinux enforcing. On main the new check fails with bootc_bootc and bootc-bootc-0 where it expected bootc_fedora and bootc-fedora-0. With this change the whole test passes through its reboots and the entries end up as bootc_fedora-45-0.conf and bootc_fedora-45-1.conf. I don't have bcvk or libvirt on this machine, so rather than through just test-tmt I installed with bootc install to-disk from a helper VM and ran the script stage by stage in qemu, with the fixed bootc bind-mounted over /usr/bin/bootc. I didn't run it with GRUB or with Type 1 entries with a kernel and initrd. They use the same function, but the new tmt check only runs on systemd-boot.

Assisted-by: AI
I reviewed and tested the changes myself.

A rollback rewrote both Type 1 entries with "bootc" as the os_id, so
bootc_fedora-45-1.conf came back as bootc_bootc-45-1.conf with the
sort key bootc-bootc-0, unlike every entry install, upgrade and switch
write. Since the sort key changes too, the entries also move relative
to anything else in the boot menu.

Take the os_id from the sort keys the entries already have, so a
rollback only swaps which one comes first. Entries with a sort key bootc
didn't write still fall back to "bootc".

Assisted-by: AI
Signed-off-by: Kristof Imeri <kristof@lanth.me>

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Johan-Liebert1
Johan-Liebert1 merged commit 27f1e64 into bootc-dev:main Nov 10, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants