Skip to content

Conversation

@alexlarsson
Copy link
Contributor

This allows you to set a non-default ostree bootloader backend. In particular, this is needed for aboot images, as otherwise the deploy will not shell out to aboot-deploy to create the required A/B boot symlinks.

PR includes a fix to make aboot-deploy actually work.

@bootc-bot bootc-bot bot requested a review from ckyrouac August 19, 2025 11:30
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 introduces support for configuring the bootloader during installation via a new bootloader option in the install configuration. This is primarily to support aboot. The changes also include a fix to use the process ID instead of /proc/self when creating the ostree sysroot, which is necessary for aboot-deploy to function correctly. The implementation looks solid, with corresponding updates to configuration merging and tests. I've left one minor comment regarding a docstring that should be updated for clarity.

@alexlarsson
Copy link
Contributor Author

Note: The install config file was the most obvious way to allow bootloader to be configured, it may not be the best approach.

/proc/self doesn't resolve correctly for subprocesses that may be
spawned. In particular, if ostree spawns aboot-deploy to update the
aboot symlinks that will fail.
let sysroot = {
let path = format!("/proc/self/fd/{}", rootfs_dir.as_fd().as_raw_fd());
let path = format!(
"/proc/{}/fd/{}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm OK with this but I think the real fix here is that everything in ostree should be using fd-relative access.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue here is that the path passed to ostree here ends up in a commandline when ostree spawns aboot-deploy. I don't see how using fd-relative access inside ostree itself can fix that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see how using fd-relative access inside ostree itself can fix that.

Because ostree turns the provided path into a fd which we should be using instead as the above PR does, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happens currently (without this change) is that the ostree deploy code will spawn /usr/bin/aboot-deploy -r /proc/self/fd/12. And then when aboot-deploy tries to read this, /proc/self/fd/12 no longer points to the correct thing.

For sure, we could make ostree::Sysroot work with a dirfd for the root path, but it would run into the same problem when it tried to spawn aboot-deploy.

/// Supported architectures for this configuration
pub(crate) match_architectures: Option<Vec<String>>,
/// Bootloader backend to use
pub(crate) bootloader: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, ideally there's a way we can detect this automatically instead.

In ostree wouldn't it be as simple as saying "if there's a /usr/bin/aboot-deploy" then use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a look at what is possible here. But sure, that would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we want to auto-detect the aboot bootloader if bootloader is set to "none" (maybe if its "auto", but that is not what bootc is doing), because it is fundamentally a pretty destructive operation. I.e. if aboot is enabled the "ostree deploy will potentially dd stuff to a raw partition, and even though its unlikely to happen accidentally I don't fee like it is worth risking it. Not to mention that it is a large change in ostree behavior.

However, I think you're right that we want to automatically detect this by just looking at the image. But we should probably do that in "bootc install" instead. I'll have a look at this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed a new version that does this instead

Copy link
Collaborator

Choose a reason for hiding this comment

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

I pushed a new version that does this instead

I don't see any changes like that?

I don't think we want to auto-detect the aboot bootloader if bootloader is set to "none" (maybe if its "auto", but that is not what bootc is doing), because it is fundamentally a pretty destructive operation.

Yes agree re historical ostree behavior, but note that bootc is basically overriding it by always setting none today. I think it does make sense to re-consider how we do autodetection at least in the bootc context because (unlike ostree) there actually is an explicit install operation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This all said, I'm overall OK to just merge this as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed a new version that does this instead

I don't see any changes like that?

I'm pretty sure I pushed it? Weird. Anyway, pushed it now.

Aboot images need to have the ostree bootloader backend set
to "aboot", otherwise the deploy during bootc install will
not create the correct boot A/B symlinks, and additionally
once booted will not correctly deploy to the aboot partition
during an update.

To see whethere an image is using aboot, we look for the "aboot.img"
file in the kernel modules dir.

NOTE: In order to correctly handle running bootc from a different
container than the to-be-installed container we look for aboot.img
in the actual commit, not just in the running container.
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Nice!

/// Supported architectures for this configuration
pub(crate) match_architectures: Option<Vec<String>>,
/// Bootloader backend to use
pub(crate) bootloader: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This all said, I'm overall OK to just merge this as is

@cgwalters cgwalters changed the title install: Support bootloader install config options (for aboot) install: Automatically configure aboot Aug 20, 2025
@cgwalters cgwalters enabled auto-merge August 20, 2025 15:56
@cgwalters
Copy link
Collaborator

At first I thought this was a flake

Error: creating build container: unable to copy from source docker://quay.io/centos-bootc/centos-bootc:stream9: copying system image from manifest list: reading blob sha256:7573f97f5d8045fa19daa4df963f4b59bf4b55738984b06f4dab6923c5e5af1b: Digest did not match, expected sha256:7573f97f5d8045fa19daa4df963f4b59bf4b55738984b06f4dab6923c5e5af1b, got sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

But thinking about it a bit more I don't know how we'd hit that unless there was actually an incorrect image on the registry. But I can't reproduce it pulling locally.

@cgwalters cgwalters merged commit 662cdee into bootc-dev:main Aug 21, 2025
26 of 27 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