Expand description
Composefs boot setup and configuration.
This module handles setting up boot entries for composefs-based deployments, including generating BLS (Boot Loader Specification) entries, copying kernel/initrd files, managing UKI (Unified Kernel Images), and configuring the ESP (EFI System Partition).
§Boot Ordering
A critical aspect of this module is boot entry ordering, which must work correctly across both Grub and systemd-boot bootloaders despite their fundamentally different sorting behaviors.
§Critical Context: Grub’s Filename Parsing
Grub does NOT read BLS fields - it parses the filename as an RPM package name! See: https://github.com/ostreedev/ostree/issues/2961
Grub’s split_package_string() parsing algorithm:
- Strip
.confsuffix - Find LAST
-→ extract release field - Find SECOND-TO-LAST
-→ extract version field - Remainder → name field
Example: kernel-5.14.0-362.fc38.conf
- name:
kernel - version:
5.14.0 - release:
362.fc38
Critical: Grub sorts by (name, version, release) in DESCENDING order.
§Bootloader Differences
§Grub
- Ignores BLS sort-key field completely
- Parses filename to extract name-version-release
- Sorts by (name, version, release) DESCENDING
- Any
-in name/version gets incorrectly split
§Systemd-boot
- Reads BLS sort-key field
- Sorts by sort-key ASCENDING (A→Z, 0→9)
- Filename is mostly irrelevant
§Implementation Strategy
Filenames (for Grub’s RPM-style parsing and descending sort):
- Format:
bootc_{os_id}-{version}-{priority}.conf - Replace
-with_in os_id to prevent mis-parsing - Primary:
bootc_fedora-41.20251125.0-1.conf→ (name=bootc_fedora, version=41.20251125.0, release=1) - Secondary:
bootc_fedora-41.20251124.0-0.conf→ (name=bootc_fedora, version=41.20251124.0, release=0) - Grub sorts: Primary (release=1) > Secondary (release=0) when versions equal
Sort-keys (for systemd-boot’s ascending sort):
- Primary:
bootc-{os_id}-0(lower value, sorts first) - Secondary:
bootc-{os_id}-1(higher value, sorts second)
§Boot Entry Ordering
After an upgrade, both bootloaders show:
- Primary: New/upgraded deployment (default boot target)
- Secondary: Currently booted deployment (rollback option)
Structs§
- BLSEntry
Path 🔒 - Expected
Boot 🔒Image Ids - Expected
Composefs 🔒Digest - The composefs digests embedded in the primary boot artifact, used to reconcile the freshly-generated boot image digest before it is mounted.
- Mounted
Image 🔒Root - A composefs image attached to a temporary directory with the ESP and a tmpfs mounted inside it, ready for bootloader installation.
- Prepared
Aboot 🔒Artifacts - Recovered
Boot 🔒Image - Secureboot
Keys - UKIInfo 🔒
- UkiComposefs
Candidate 🔒 - One composefs digest from a UKI command line.
Enums§
- Boot
Setup 🔒Type - Boot
Type - UKIDigest
Mismatch 🔒 - UkiCandidate
Format 🔒 - The EROFS format a UKI composefs kernel argument claims for its digest.
Constants§
- AUTH_
EXT 🔒 - BOOTC_
AUTOENROLL_ 🔒PATH - BOOTC_
UKI_ 🔒DIR - We want to be able to control the ordering of UKIs so we put them in a directory that’s not the directory specified by the BLS spec. We do this because we want systemd-boot to only look at our config files and not show the actual UKIs in the bootloader menu This is relative to the ESP
- EFI_
LINUX 🔒 - The EFI Linux directory
- EFI_
UUID_ 🔒FILE - Contains the EFP’s filesystem UUID. Used by grub
- ESP_
MOUNT_ 🔒DATA - FAT mount options: owner-only permissions on files (0600) and dirs (0700).
- ESP_
MOUNT_ 🔒FLAGS - Mount flags shared by all ESP mounts: non-executable, no setuid.
- FILENAME_
PRIORITY_ 🔒PRIMARY - Filename release field for primary (new/upgraded) entry. Grub parses this as the “release” field and sorts descending, so “1” > “0”.
- FILENAME_
PRIORITY_ 🔒SECONDARY - Filename release field for secondary (currently booted) entry.
- GLOBAL_
UKI_ 🔒ADDONS_ DIR - Directory (relative to the ESP) where systemd-stub looks for UKI addons that apply
to every UKI, as opposed to addons scoped to a single UKI (which live alongside
it under
BOOTC_UKI_DIR). Unlike per-UKI addons, these aren’t tied to a single deployment, so they’re neither namespaced by deployment verity nor cleaned up by GC. - INITRD 🔒
- SORTKEY_
PRIORITY_ 🔒PRIMARY - Sort-key priority for primary (new/upgraded) entry. Systemd-boot sorts by sort-key in ascending order, so “0” appears before “1”.
- SORTKEY_
PRIORITY_ 🔒SECONDARY - Sort-key priority for secondary (currently booted) entry.
- STAGED_
GLOBAL_ 🔒UKI_ ADDONS_ DIR - Where all staged Global UKI Addons are kept
- VMLINUZ 🔒
Functions§
- aboot_
disk_ 🔒partition_ payloads - aboot_
partition_ 🔒path - compute_
aboot_ 🔒boot_ digest - compute_
boot_ 🔒digest - Compute SHA256Sum of VMlinuz + Initrd
- compute_
boot_ 🔒digest_ aboot - compute_
boot_ 🔒digest_ type1 - compute_
boot_ 🔒digest_ uki - Compute SHA256Sum of .linux + .initrd section of the UKI
- ensure_
correct_ 🔒composefs_ digest - Validates that the freshly-generated boot image digest
computed_idmatches what’s embedded in the UKI (if any), and if not, searches for an [composefs_oci::XattrFiltering] mode whose boot image digest does match via [composefs_oci::find_matching_boot_image], before giving up. - expected_
boot_ 🔒image_ ids - Associate every accepted boot image with its EROFS serialization format.
A UKI’s V1 candidate must never be accepted merely because its digest is a
valid V2 image (or vice versa).
selectedis the freshly generated image; recovered images are added with their actual format by the recovery path. - file_
from_ 🔒type2_ entry - Return a UKI/UKI Addon as a file descriptor from a
Type2Entryboot entry - find_
expected_ 🔒composefs_ digest - Scans
entriesfor the primary UKI or aboot payload and extracts the composefs digests embedded in its kernel cmdline. - find_
vmlinuz_ 🔒initrd_ duplicate - Given the SHA256 sum of current VMlinuz + Initrd combo, find boot entry with the same SHA256Sum
- get_
efi_ 🔒uuid_ source - Returns the beginning of the grub2/user.cfg file where we source a file containing the ESPs filesystem UUID
- get_
global_ 🔒uki_ addon_ name - Returns the name of a global UKI Addon directory given name
with or without the
.addon.efiprefix - get_
scoped_ 🔒uki_ addon_ name - Returns the name of a scoped/local UKI Addon directory given name
with or without the
.addon.efiprefix - get_
secureboot_ 🔒keys - get_
type1_ 🔒dir_ name - Returns the name of the directory where we store Type1 boot entries
- get_
uki_ 🔒addon_ dir_ name - Returns the name of a UKI Addon directory given verity digest
- get_
uki_ 🔒name - Returns the name of a UKI given verity digest
- grub_
bls_ 🔒abs_ entries_ path - The absolute path GRUB resolves the kernels and initramfses in BLS entries
against: the root of the filesystem holding
grub_boot_path. - image_
bootloader 🔒 - image_
fsverity_ 🔒policy - Inspect primary boot artifacts to discover the image’s fs-verity policy before creating the durable repository. Final artifact validation occurs while installing the boot artifact.
- install_
aboot_ 🔒disk_ payload - install_
composefs_ 🔒bootloader - install_
ukiboot 🔒 - mount_
esp - Fresh
mount(2)of the ESP into a tempdir. Returns EBUSY if the device is already mounted in the current mount namespace; callers should usemount_esp_readonlyormount_esp_writableinstead of this primitive so that pre-existing mounts are handled. - mount_
esp_ 🔒at - Mount the ESP from
deviceat the given path and return a guard that synchronously unmounts (and flushes) it on drop. - mount_
esp_ readonly - Get a read-only view of the ESP for the provided device, gracefully
handling the case where the ESP is already mounted in the root mount
namespace (e.g. via
systemd.mount-extra=UUID=<ESP>:/boot:auto:ro). If the ESP is already mounted, that mount is cloned privately into a tempdir; otherwise a fresh read-write mount is performed. The returned mount may be rw or ro; callers must not write through it. - mount_
esp_ writable - Get a read-write view of the ESP for the provided device, gracefully handling the case where the ESP is already mounted (possibly read-only) in the current mount namespace.
- os_
id_ 🔒from_ sort_ key - Returns the os_id in a sort key from
primary_sort_keyorsecondary_sort_key, orNoneif it isn’t in their format. - parse_
os_ release - Parses /usr/lib/os-release and returns (id, title, version) Expects a reference to the root of the filesystem, or the root of a mounted EROFS
- parse_
uki_ 🔒cmdline - Makes sure there is no composefs= cmdline in a global UKI Addon Makes sure if we already have a parsed cmdline, we don’t find another one
- parse_
uki_ 🔒composefs_ candidates - Parse every composefs argument emitted by supported bootc UKIs.
- pe_
output_ 🔒dir - Determines the directory (under
mounted_efi) that a PE binary should be written to. - prepare_
composefs_ 🔒aboot_ artifacts - primary_
boot_ 🔒entry - Pick the first real bootable entry, skipping UKI addons.
- primary_
sort_ 🔒key - Generate sort key for the primary (new/upgraded) boot entry. Format: bootc-{id}-0 Systemd-boot sorts ascending by sort-key, so “0” comes first. Grub ignores sort-key and uses filename/version ordering.
- primary_
uki_ 🔒candidate - Retain the historical V1 preference for the deployment identity while validating every fallback candidate. This avoids changing the naming of existing dual-format UKIs when their kernel arguments are reordered.
- print_
uki_ 🔒dumpfile_ diff - print_
uki_ 🔒dumpfile_ diff_ on_ mismatch - Print the dumpfile diff when a UKI digest mismatch is about to escape.
- read_
aboot_ 🔒payload - read_
dumpfile_ 🔒from_ fs - read_
regular_ 🔒file - reconcile_
uki_ 🔒candidates - The repository-independent part of
ensure_correct_composefs_digest: every UKI candidate must name a boot image of an acceptable format, found either amongexpected_idsor viafind_matching. - replace_
composefs_ 🔒karg - Replace either karg spelling to ensure only the selected EROFS format remains.
- resolve_
boot_ 🔒image_ match - Interprets the result of searching for a boot image whose digest matches
expected(see [composefs_oci::find_matching_boot_image]): uses the matching mode’s digest if one was found, or fails with an error listing every combination tried if not. - secondary_
sort_ 🔒key - Generate sort key for the secondary (currently booted) boot entry. Format: bootc-{id}-1
- setup_
composefs_ 🔒bls_ boot - Sets up and writes BLS entries and binaries (VMLinuz + Initrd) to disk
- setup_
composefs_ 🔒boot - setup_
composefs_ 🔒uki_ boot - stage_
global_ 🔒uki_ addons - Copies Global UKI Addons from loader/addons to loader/addons.staged in case of an upgrade/switch
- type1_
entry_ conf_ file_ name - Generate BLS Type 1 entry filename compatible with Grub’s RPM-style parsing.
- uki_
candidates_ 🔒policy - uki_
file_ 🔒name - validate_
aboot_ 🔒composefs_ candidates - validate_
aboot_ 🔒disk_ layout - validate_
bootloader 🔒 - validate_
composefs_ 🔒aboot_ payload - validate_
uki_ 🔒candidates - write_
aboot_ 🔒partition - write_
bls_ 🔒boot_ entries_ to_ disk - write_
grub_ 🔒uki_ menuentry - write_
pe_ 🔒to_ esp - Writes a PortableExecutable to ESP along with any PE specific or Global addons
- write_
systemd_ 🔒uki_ config - write_
type1_ 🔒entries - Writes a deployment’s Type 1 boot entry. A staged deployment replaces any earlier staged one, whose entry may have another version in its file name, and keeps the booted deployment’s entry next to it.