Skip to content

Commit 966002e

Browse files
committed
install: Don't require EFI if booted via BIOS and doing alongside
Today Anaconda defaults to setting up the bootloader with source == target mode; on x86_64 that means if booted via BIOS the system is installed just with BIOS, and EFI if booted via EFI. When we're doing an alongside install we hence cannot require an ESP. Signed-off-by: Colin Walters <[email protected]>
1 parent b3e35c4 commit 966002e

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

lib/src/bootloader.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::os::unix::prelude::PermissionsExt;
2+
use std::path::Path;
23

34
use anyhow::{Context, Result};
45
use camino::Utf8Path;
@@ -51,20 +52,43 @@ fn install_grub2_efi(efidir: &Dir, uuid: &str) -> Result<()> {
5152
Ok(())
5253
}
5354

55+
/// Return `true` if the system is booted via EFI
56+
pub(crate) fn is_efi_booted() -> Result<bool> {
57+
if !super::install::ARCH_USES_EFI {
58+
return Ok(false);
59+
}
60+
Path::new("/sys/firmware/efi")
61+
.try_exists()
62+
.map_err(Into::into)
63+
}
64+
5465
#[context("Installing bootloader")]
5566
pub(crate) fn install_via_bootupd(
5667
device: &Utf8Path,
5768
rootfs: &Utf8Path,
5869
boot_uuid: &str,
70+
is_alongside: bool,
5971
) -> Result<()> {
6072
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
61-
let args = ["backend", "install"].into_iter().chain(verbose).chain([
62-
"--src-root",
63-
"/",
64-
"--device",
65-
device.as_str(),
66-
rootfs.as_str(),
67-
]);
73+
let using_efi = is_efi_booted()?;
74+
// If we're doing an alongside install on a BIOS-booted system, don't do EFI
75+
let is_bios_only = cfg!(target_arch = "x86_64") && !using_efi && is_alongside;
76+
let component_args = if is_bios_only {
77+
Some("--component=BIOS")
78+
} else {
79+
None
80+
};
81+
let args = ["backend", "install"]
82+
.into_iter()
83+
.chain(verbose)
84+
.chain(component_args)
85+
.chain([
86+
"--src-root",
87+
"/",
88+
"--device",
89+
device.as_str(),
90+
rootfs.as_str(),
91+
]);
6892
Task::new_and_run("Running bootupctl to install bootloader", "bootupctl", args)?;
6993

7094
let grub2_uuid_contents = format!("set BOOT_UUID=\"{boot_uuid}\"\n");
@@ -73,7 +97,7 @@ pub(crate) fn install_via_bootupd(
7397
let bootfs =
7498
Dir::open_ambient_dir(bootfs, cap_std::ambient_authority()).context("Opening boot")?;
7599

76-
if super::install::ARCH_USES_EFI {
100+
if super::install::ARCH_USES_EFI && !is_bios_only {
77101
let efidir = bootfs.open_dir("efi").context("Opening efi")?;
78102
install_grub2_efi(&efidir, &grub2_uuid_contents)?;
79103
}

lib/src/install.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,12 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
861861
.get_boot_uuid()?
862862
.or(rootfs.rootfs_uuid.as_deref())
863863
.ok_or_else(|| anyhow!("No uuid for boot/root"))?;
864-
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, boot_uuid)?;
864+
crate::bootloader::install_via_bootupd(
865+
&rootfs.device,
866+
&rootfs.rootfs,
867+
boot_uuid,
868+
rootfs.is_alongside,
869+
)?;
865870
tracing::debug!("Installed bootloader");
866871

867872
// If Ignition is specified, enable it

0 commit comments

Comments
 (0)