Skip to content

Conversation

@Johan-Liebert1
Copy link
Collaborator

Add a composefs-backend option to system-reinstall-bootc

Fix a bug with installing grub bootloader where we were using paths absolute to rootfs even if /boot was a separate partition

If `/boot` is a separate partition, the kernel + initrd paths need to be
absolute to `/`, which was not the case until now as they were always
absolute to the actual rootfs

Signed-off-by: Pragyan Poudyal <[email protected]>
@github-actions github-actions bot added the area/system-reinstall-bootc Issues related to system-reinstall-botoc label Nov 3, 2025
@bootc-bot bootc-bot bot requested a review from gursewak1997 November 3, 2025 06:50
@Johan-Liebert1 Johan-Liebert1 added area/composefs Issues related to composefs area/install Issues related to `bootc install` labels Nov 3, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a composefs-backend option for system reinstallation and fixes a bug in GRUB bootloader path generation when /boot is a separate partition. The changes are well-implemented across the configuration and command-line layers. The bug fix correctly determines the absolute path prefix, and the refactoring to use Utf8PathBuf::join improves code clarity and safety. I've included one suggestion to improve variable naming for better readability.

Comment on lines +424 to +446
Bootloader::Grub => {
let root = Dir::open_ambient_dir(&root_path, ambient_authority())
.context("Opening root path")?;

// Grub wants the paths to be absolute against the mounted drive that the kernel +
// initrd live in
//
// If "boot" is a partition, we want the paths to be absolute to "/"
let entries_path = match root.is_mountpoint("boot")? {
Some(true) => "/",
// We can be fairly sure that the kernels we target support `statx`
Some(false) | None => "/boot",
};

(
BLSEntryPath {
entries_path: root_path.join("boot"),
config_path: root_path.join("boot"),
abs_entries_path: entries_path.into(),
},
None,
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For clarity and to avoid confusion, it would be better to rename the local variable entries_path. It currently has the same name as the entries_path field in the BLSEntryPath struct, but they represent different concepts. The local variable is a path prefix for the bootloader configuration, while the struct field is the directory where kernel/initrd files are written. Renaming it to something like abs_path_prefix would make the code easier to understand.

        Bootloader::Grub => {
            let root = Dir::open_ambient_dir(&root_path, ambient_authority())
                .context("Opening root path")?;

            // Grub wants the paths to be absolute against the mounted drive that the kernel +
            // initrd live in
            //
            // If "boot" is a partition, we want the paths to be absolute to "/"
            let abs_path_prefix = match root.is_mountpoint("boot")? {
                Some(true) => "/",
                // We can be fairly sure that the kernels we target support `statx`
                Some(false) | None => "/boot",
            };

            (
                BLSEntryPath {
                    entries_path: root_path.join("boot"),
                    config_path: root_path.join("boot"),
                    abs_entries_path: abs_path_prefix.into(),
                },
                None,
            )
        }

@Johan-Liebert1 Johan-Liebert1 changed the title System reinstall System reinstall composefs Nov 3, 2025
@cgwalters cgwalters merged commit 52f49b5 into bootc-dev:main Nov 4, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/composefs Issues related to composefs area/install Issues related to `bootc install` area/system-reinstall-bootc Issues related to system-reinstall-botoc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants