Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/lib/src/bootc_composefs/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ const AUTH_EXT: &str = "auth";
/// This is relative to the ESP
pub(crate) const BOOTC_UKI_DIR: &str = "EFI/Linux/bootc";

// These are the modules we insmod in out menu config files
const GRUB_MODULES_USED: [&str; 2] = ["fat.mod", "chain.mod"];

fn grub_efi_module_dir() -> Option<&'static str> {
match std::env::consts::ARCH {
"aarch64" => Some("arm64-efi"),
"x86_64" => Some("x86_64-efi"),
"riscv64" => Some("riscv64-efi"),
_ => None,
}
}

/// 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
Expand Down Expand Up @@ -2158,6 +2170,27 @@ pub(crate) async fn setup_composefs_boot(
Some(bind_boot_path.as_path()),
)?;

if matches!(postfetch.detected_bootloader, Bootloader::Grub) {
// The menu config files insmod some modules, these may be either built
// into the GRUB EFI binary, or loaded from /boot/grub2. For example, the
// fedora aarch64 grub doesn't include chain.mod. We install all the modules
// we can find to avoid potential problems.
Comment on lines +2174 to +2177

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be bootupd's job

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How can bootupd know that we're using these particular grub modules though? Maybe it should copy all modules?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess it could copy all modules? Its not that big anyway.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Right now if a static grub config is used (which is the default for bootupd) that static config is embedded in that package. And that static config should certainly include or install modules it needs.

I really want to avoid having bootc know too many details of grub because it's a huge mess, that stuff should get squirreled away in bootupd so we can keep this project kind of detached from the reality of the so many years of technical debt.

One hope is that grub-cc fixes some of this.

But actually though,

fedora aarch64 grub doesn't include chain.mod.

Isn't that just something to fix there?

I mean let's at least weigh options like that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Honestly, i think for fedora we should probably fix it in the grub build. However, we might want to support non-fedora bootc images that aren't built that way? I'll have a look at the bootupd side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I filed a fedora bug, lets see what they think: https://bugzilla.redhat.com/show_bug.cgi?id=2545182

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here is the bootupd version of this: coreos/bootupd#1165

if let Some(module_dir) = grub_efi_module_dir() {
for module in GRUB_MODULES_USED {
let source = format!("usr/lib/grub/{module_dir}/{module}");
if mounted_root.dir().try_exists(&source)? {
let target = format!("boot/grub2/{module_dir}");
root_setup.physical_root.create_dir_all(&target)?;
let target = root_setup.physical_root.open_dir(&target)?;
mounted_root
.dir()
.copy(&source, &target, module)
.with_context(|| format!("Installing GRUB module {module}"))?;
}
}
}
}

// FIXME: Remove this hack once we have support in bootupd
if matches!(postfetch.detected_bootloader, Bootloader::GrubCC) {
// bootupctl wrote this under the physical root's real /boot (via
Expand Down
Loading