Skip to content

Commit ed80429

Browse files
committed
efi: install grub.cfg under new vendor during updates
When doing switches from RHEL 10 to Fedora 43, after reboot, check grub.cfg and bootuuid.cfg are in old vendor redhat, that will make the machine fails to boot a second time since grub.cfg cannot be found. We need to install the 2 files under new vendor during updates. See #1024
1 parent 17f4ec7 commit ed80429

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/efi.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,31 @@ impl Component for Efi {
483483

484484
for esp in esp_devices {
485485
let destpath = &self.ensure_mounted_esp(rootcxt.path.as_ref(), Path::new(&esp))?;
486-
let destdir = openat::Dir::open(&destpath.join("EFI")).context("opening EFI dir")?;
486+
let dest_efi = destpath.join("EFI");
487+
let destdir = openat::Dir::open(&dest_efi).context("opening EFI dir")?;
487488
validate_esp_fstype(&destdir)?;
489+
490+
// Get old vendor name from mounted efi before applying
491+
let Some(old_vendor) = self.get_efi_vendor(&dest_efi)? else {
492+
anyhow::bail!("Failed to find efi vendor at {}", dest_efi.display());
493+
};
488494
log::trace!("applying diff: {}", &diff);
489495
filetree::apply_diff(&updated, &destdir, &diff, None)
490496
.context("applying filesystem changes")?;
491497

498+
// Install grub.cfg under new vendor
499+
{
500+
// Get new vendor name
501+
let sysroot = rootcxt.path.as_std_path();
502+
let Some(new_vendor) = self.get_efi_vendor(&sysroot.join(&updated_path))? else {
503+
anyhow::bail!("Failed to find efi vendor in new update");
504+
};
505+
if new_vendor != old_vendor && destdir.exists(&old_vendor)? {
506+
grubconfigs::install(sysroot_dir, None, Some(&new_vendor), true)?;
507+
destdir.remove_all(&old_vendor)?;
508+
}
509+
}
510+
492511
// Do the sync before unmount
493512
fsfreeze_thaw_cycle(destdir.open_file(".")?)?;
494513
drop(destdir);

0 commit comments

Comments
 (0)