diff --git a/docs/release-notes.md b/docs/release-notes.md index e6398ae24..fc6c79b24 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,7 @@ nav_order: 8 Major changes: +- Support alternative grub2/50_coreos.cfg location for grub console configuration Minor changes: diff --git a/src/install.rs b/src/install.rs index c2a8cc56b..0429eeffc 100644 --- a/src/install.rs +++ b/src/install.rs @@ -636,11 +636,17 @@ fn write_console(mountpoint: &Path, platform: Option<&str>, consoles: &[Console] // set grub commands if grub_commands != metal_spec.grub_commands { - let path = mountpoint.join("grub2/grub.cfg"); - let grub_cfg = fs::read_to_string(&path).context("reading grub.cfg")?; + // prefer the new grub2/50_coreos.cfg, but fallback to grub2/grub.cfg + let mut name = "grub2/50_coreos.cfg"; + let mut path = mountpoint.join(name); + if !path.exists() { + name = "grub2/grub.cfg"; + path = mountpoint.join(name); + } + let grub_cfg = fs::read_to_string(&path).with_context(|| format!("reading {}", name))?; let new_grub_cfg = update_grub_cfg_console_settings(&grub_cfg, &grub_commands) - .context("updating grub.cfg")?; - fs::write(&path, new_grub_cfg).context("writing grub.cfg")?; + .with_context(|| format!("updating {}", name))?; + fs::write(&path, new_grub_cfg).with_context(|| format!("writing {}", name))?; } Ok(()) }