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§
Enums§
Constants§
- AUTH_
EXT 🔒 - BOOTC_
AUTOENROLL_ 🔒PATH - EFI_
LINUX 🔒 - The EFI Linux directory
- EFI_
UUID_ 🔒FILE - Contains the EFP’s filesystem UUID. Used by grub
- 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.
- 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.
- SYSTEMD_
LOADER_ 🔒CONF_ PATH - SYSTEMD_
TIMEOUT 🔒 - Timeout for systemd-boot bootloader menu
- SYSTEMD_
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
- VMLINUZ 🔒
Functions§
- compute_
boot_ 🔒digest - Compute SHA256Sum of VMlinuz + Initrd
- compute_
boot_ 🔒digest_ uki - Compute SHA256Sum of .linux + .initrd section of the UKI
- find_
vmlinuz_ 🔒initrd_ duplicates - 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_
esp_ partition - get_
secureboot_ 🔒keys - get_
sysroot_ parent_ dev - mount_
esp - Mount the ESP from the provided device
- parse_
os_ 🔒release - Parses /usr/lib/os-release and returns (id, title, version)
- 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.
- 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 - type1_
entry_ conf_ file_ name - Generate BLS Type 1 entry filename compatible with Grub’s RPM-style parsing.
- 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