Skip to content

Commit 5d31c06

Browse files
committed
install: support grub2/50_coreos.cfg for console replacement
Upstream we are starting to use grub configs that are partially baked into bootupd [1] and partially baked into the image via the OS vendor (in our case a grub2/50_coreos.cfg file [2]). Let's look first to see if grub2/50_coreos.cfg exists when trying to write new console settings before falling back to grub2/grub.cfg. [1] coreos/bootupd#543 [2] coreos/fedora-coreos-config#2769
1 parent 82a7d0c commit 5d31c06

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/release-notes.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ nav_order: 8
88

99
Major changes:
1010

11+
- Support alternative grub2/50_coreos.cfg location for grub console configuration
1112

1213
Minor changes:
1314

src/install.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,17 @@ fn write_console(mountpoint: &Path, platform: Option<&str>, consoles: &[Console]
636636

637637
// set grub commands
638638
if grub_commands != metal_spec.grub_commands {
639-
let path = mountpoint.join("grub2/grub.cfg");
640-
let grub_cfg = fs::read_to_string(&path).context("reading grub.cfg")?;
639+
// prefer the new grub2/50_coreos.cfg, but fallback to grub2/grub.cfg
640+
let mut name = "grub2/50_coreos.cfg";
641+
let mut path = mountpoint.join(name);
642+
if !path.exists() {
643+
name = "grub2/grub.cfg";
644+
path = mountpoint.join(name);
645+
}
646+
let grub_cfg = fs::read_to_string(&path).with_context(|| format!("reading {}", name))?;
641647
let new_grub_cfg = update_grub_cfg_console_settings(&grub_cfg, &grub_commands)
642-
.context("updating grub.cfg")?;
643-
fs::write(&path, new_grub_cfg).context("writing grub.cfg")?;
648+
.with_context(|| format!("updating {}", name))?;
649+
fs::write(&path, new_grub_cfg).with_context(|| format!("writing {}", name))?;
644650
}
645651
Ok(())
646652
}

0 commit comments

Comments
 (0)