Skip to content

Conversation

@Johan-Liebert1
Copy link
Collaborator

Parse toml files in usr/lib/bootc/kargs.d and append them to kernel
cmdline on install and upgrade/switch. Also, copy over current
deployment's cmdline args on upgrade/switch to another deployment

storage: Add boot_dir and esp fields

We have a lot of places where we mount the ESP temporarily and a lot of
switch cases for Grub's vs SystemdBoot's 'boot' directory.

We add a boot_dir field in Storage which points to /sysroot/boot for
systems with Grub as the bootloader and points to the ESP for systems
with SystemdBoot as the bootloader.

Also we mount the ESP temporarily while creating the storage struct,
which cleans up the code quite a bit.

@bootc-bot bootc-bot bot requested a review from jmarrero November 19, 2025 11:15
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 two main changes. First, it adds support for reading kernel arguments from .toml files in /usr/lib/bootc/kargs.d during installation and upgrades. This is a valuable feature for customizing kernel command line arguments. Second, it refactors the storage handling by introducing boot_dir and esp fields in the Storage struct. This significantly cleans up the code by centralizing the logic for accessing the boot directory and the ESP, removing redundant ESP mounting logic across multiple files. The changes are well-implemented and improve both functionality and code maintainability. I have one minor suggestion to improve an error message for better debuggability.

Cmdline::from(options)
}

_ => anyhow::bail!("Found NonEFI config"),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error message "Found NonEFI config" is confusing. This branch is executed when a config type other than NonEFI is found (e.g., EFI or Unknown). A more accurate message would be "Unsupported BLS config type, expected NonEFI", which would make debugging easier.

Suggested change
_ => anyhow::bail!("Found NonEFI config"),
_ => anyhow::bail!("Unsupported BLS config type, expected NonEFI"),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We change the key efi to uki here #1780
This would need to change anyway afterwards

@Johan-Liebert1
Copy link
Collaborator Author

The big assumption here is that all composefs systems will boot via UEFI. That being said, we were already making this assumption in a few other places

@Johan-Liebert1
Copy link
Collaborator Author

I think I overwrote some of my changes on force pushing. Marking this as draft for now

@Johan-Liebert1 Johan-Liebert1 marked this pull request as draft November 19, 2025 13:07
/// Directory holding the physical root
pub physical_root: Dir,

/// The 'boot' directory, useful and `Some` only for composefs systems
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's more that ostree::Sysroot handles this itself right now right?

And that kind of gets to the next thing. The way I'd been thinking about struct Storage is closer to an abstraction over ostree::Repo and composefs::Repository.

Maybe arguably it'd be slightly cleaner to actually have a struct SystemRoot that has these new members, and has an impl Deref<Target=Storage>?

But eh.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The way I'd been thinking about struct Storage is closer to an abstraction over ostree::Repo and composefs::Repository

We do have physical_root and run in struct Storage so not quite an abstraction over Repository...
Maybe we could put these in BootedComposefs, but that doesn't sound right either


let fname_str = fname
.to_str()
.ok_or_else(|| anyhow::anyhow!("Failed to get filename as string"))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps arguably we should skip in this case?

I think we want a helper fn for this that includes the path in the error message if we do propagate an error.

(Non-UTF8 filenames is just a giant mess)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps arguably we should skip in this case?

I think we can skip it, and maybe have in the docs that we only support UTF8 filenames

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Skipping any non UTF-8 named files with a warning

Parse toml files in usr/lib/bootc/kargs.d and append them to kernel
cmdline on install and upgrade/switch. Also, copy over current
deployment's cmdline args on upgrade/switch to another deployment

Signed-off-by: Pragyan Poudyal <[email protected]>
We have a lot of places where we mount the ESP temporarily and a lot of
switch cases for Grub's vs SystemdBoot's 'boot' directory.

We add a `boot_dir` field in Storage which points to `/sysroot/boot` for
systems with Grub as the bootloader and points to the ESP for systems
with SystemdBoot as the bootloader.

Also we mount the ESP temporarily while creating the storage struct,
which cleans up the code quite a bit.

Signed-off-by: Pragyan Poudyal <[email protected]>
@Johan-Liebert1 Johan-Liebert1 marked this pull request as ready for review November 20, 2025 08:41
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