Skip to content

composefs/grub: Type 1 entry order is arbitrary when os-release has no VERSION_ID/VERSION #2669

Open

Description

@hanthor

Summary

When composefs uses GRUB with Type 1 entries, bootc orders the entries by file name, descending (get_sorted_type1_boot_entries, Bootloader::Grub → b.filename.cmp(&a.filename), see #2221). The file name is bootc_{os_id}-{version}-{priority}.conf (type1_entry_conf_file_name). version comes from VERSION_ID, then VERSION, in /usr/lib/os-release.

Some os-release files have neither key, for example Debian sid/testing and Arch Linux. For those, setup_composefs_bls_boot falls back to the deployment's verity digest:

// crates/lib/src/bootc_composefs/boot.rs (main @ 2a59b59, also v1.16.10)
version_opt.unwrap_or_else(|| id.to_hex()),

As a result, the version field is a random hex string that changes with every deployment, and it sorts before the priority field. After an upgrade:

loader/entries/bootc_debian-3f…(new digest)…-1.conf   # primary (new)
loader/entries/bootc_debian-c0…(old digest)…-0.conf   # secondary (booted)

The descending file-name order puts the old deployment first here, because c > 3. So bootc (and GRUB's blscfg, which uses the same name-version-release order) treats the old deployment as the default, and the upgrade is never booted. With other digests the new one wins. bootc rollback swaps only the priority field, so it is just as arbitrary.

With systemd-boot this does not happen, because the sort-key (bootc-{os_id}-{0,1}) comes first.

Reproducer

  1. bootc install to-disk --composefs-backend --bootloader grub an image whose /usr/lib/os-release has no VERSION_ID and no VERSION. A Debian sid based bootc image works, and so does the stock Arch os-release.
  2. bootc upgrade to a new image, then reboot so that bootc-finalize-staged runs.
  3. ls /sysroot/boot/loader/entries: the two entries differ only in the digest and the priority. The -1 (new) entry is first only when its digest sorts higher.

The logic needs no VM. Feed two BLSConfigs named as above to get_sorted_type1_boot_entries_helper(.., Bootloader::Grub), and the order follows the digests.

Possible fix

When os-release has no version, use a constant (for example 0) in place of the digest. Then the priority (release) field decides between the deployments of one OS, as it does when VERSION_ID stays the same across builds. The title/version shown to the user can keep the digest.

Context

We hit this while booting TunaOS flounder:gnome-sid (Debian sid, bootc 1.16.10, composefs) through a GRUB chain (tuna-os/wootc#768).

Activity

  1. added
    bug
    triaged
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions