Skip to content

Commit 9ebefc1

Browse files
committed
lib: Fallback to partition table for ESP
Currently, the installation requires the ESP to be explicitly mounted. This change allows the bootloader logic to locate the ESP by scanning the partition table if the mount check fails. The baseline installation path is updated to allow this fallback, improving robustness when the filesystem is not fully mounted. Signed-off-by: Daniele Guarascio <guarascio.daniele@gmail.com>
1 parent 67361c4 commit 9ebefc1

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ pub(crate) async fn setup_composefs_boot(
12911291
&state.config_opts,
12921292
None,
12931293
get_secureboot_keys(&mounted_fs, BOOTC_AUTOENROLL_PATH)?,
1294+
root_setup.require_esp_mount,
12941295
)?;
12951296
}
12961297

crates/lib/src/bootloader.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ pub(crate) fn require_boot_efi_mount(root: &Dir) -> Result<String> {
7272
Ok(source)
7373
}
7474

75+
/// Helper to find the ESP device, either via mount or partition table scan
76+
pub(crate) fn get_esp_device(
77+
root: &Dir,
78+
device_info: &PartitionTable,
79+
require_mount: bool,
80+
) -> Result<String> {
81+
if require_mount {
82+
require_boot_efi_mount(root)
83+
} else {
84+
match require_boot_efi_mount(root) {
85+
Ok(p) => Ok(p),
86+
Err(e) => {
87+
tracing::debug!(
88+
"ESP mount check failed in permissive mode: {e}; falling back to partition table scan"
89+
);
90+
let esp = esp_in(device_info)?;
91+
Ok(esp.node.clone())
92+
}
93+
}
94+
}
95+
}
96+
7597
/// Determine if the invoking environment contains bootupd, and if there are bootupd-based
7698
/// updates in the target root.
7799
#[context("Querying for bootupd")]
@@ -180,13 +202,14 @@ pub(crate) fn install_via_bootupd(
180202
#[context("Installing bootloader")]
181203
pub(crate) fn install_systemd_boot(
182204
root: &Dir,
183-
_device: &PartitionTable,
205+
device: &PartitionTable,
184206
_rootfs: &Utf8Path,
185207
_configopts: &crate::install::InstallConfigOpts,
186208
_deployment_path: Option<&str>,
187209
autoenroll: Option<SecurebootKeys>,
210+
require_mount: bool,
188211
) -> Result<()> {
189-
let esp_device = require_boot_efi_mount(root)?;
212+
let esp_device = get_esp_device(root, device, require_mount)?;
190213

191214
let esp_mount = mount_esp(&esp_device).context("Mounting ESP")?;
192215
let esp_path = Utf8Path::from_path(esp_mount.dir.path())

crates/lib/src/install/baseline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,6 @@ pub(crate) fn install_create_rootfs(
496496
boot,
497497
kargs,
498498
skip_finalize: false,
499-
require_esp_mount: true,
499+
require_esp_mount: false,
500500
})
501501
}

0 commit comments

Comments
 (0)