Skip to content

Commit 1b5943a

Browse files
committed
composefs: Walk parent devices to find ESP partition
The composefs BLS and UKI boot setup paths called find_partition_of_esp() directly on the device, which fails when the root filesystem is on an LVM logical volume (the ESP is on the parent disk, not the LV). The store module had the same issue via require_single_root() + find_partition_of_esp(). Switch all call sites to find_colocated_esps() which walks up to the physical disk(s) via find_all_roots() before searching for the ESP, consistent with what install_systemd_boot and mount_esp_part already do. Assisted-by: Claude Code (Opus 4) Signed-off-by: ckyrouac <ckyrouac@redhat.com>
1 parent abc6d8e commit 1b5943a

2 files changed

Lines changed: 60 additions & 15 deletions

File tree

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,18 @@ pub(crate) fn setup_composefs_bls_boot(
529529
ComposefsCmdline::build(&id_hex, state.composefs_options.allow_missing_verity);
530530
cmdline_options.extend(&Cmdline::from(&composefs_cmdline.to_string()));
531531

532-
// Locate ESP partition device
533-
let esp_part = root_setup.device_info.find_partition_of_esp()?;
532+
// Locate ESP partition device by walking up to the root disk(s)
533+
let esp_part = root_setup
534+
.device_info
535+
.find_colocated_esps()?
536+
.and_then(|mut v| {
537+
if v.is_empty() {
538+
None
539+
} else {
540+
Some(v.remove(0))
541+
}
542+
})
543+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
534544

535545
(
536546
root_setup.physical_root_path.clone(),
@@ -567,10 +577,18 @@ pub(crate) fn setup_composefs_bls_boot(
567577
.context("Failed to create 'composefs=' parameter")?;
568578
cmdline.add_or_modify(&param);
569579

570-
// Locate ESP partition device
571-
let root_dev =
572-
bootc_blockdev::list_dev_by_dir(&storage.physical_root)?.require_single_root()?;
573-
let esp_dev = root_dev.find_partition_of_esp()?;
580+
// Locate ESP partition device by walking up to the root disk(s)
581+
let root_dev = bootc_blockdev::list_dev_by_dir(&storage.physical_root)?;
582+
let esp_dev = root_dev
583+
.find_colocated_esps()?
584+
.and_then(|mut v| {
585+
if v.is_empty() {
586+
None
587+
} else {
588+
Some(v.remove(0))
589+
}
590+
})
591+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
574592

575593
(
576594
Utf8PathBuf::from("/sysroot"),
@@ -1103,7 +1121,18 @@ pub(crate) fn setup_composefs_uki_boot(
11031121
BootSetupType::Setup((root_setup, state, postfetch, ..)) => {
11041122
state.require_no_kargs_for_uki()?;
11051123

1106-
let esp_part = root_setup.device_info.find_partition_of_esp()?;
1124+
// Locate ESP partition device by walking up to the root disk(s)
1125+
let esp_part = root_setup
1126+
.device_info
1127+
.find_colocated_esps()?
1128+
.and_then(|mut v| {
1129+
if v.is_empty() {
1130+
None
1131+
} else {
1132+
Some(v.remove(0))
1133+
}
1134+
})
1135+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
11071136

11081137
(
11091138
root_setup.physical_root_path.clone(),
@@ -1118,10 +1147,18 @@ pub(crate) fn setup_composefs_uki_boot(
11181147
let sysroot = Utf8PathBuf::from("/sysroot"); // Still needed for root_path
11191148
let bootloader = host.require_composefs_booted()?.bootloader.clone();
11201149

1121-
// Locate ESP partition device
1122-
let root_dev =
1123-
bootc_blockdev::list_dev_by_dir(&storage.physical_root)?.require_single_root()?;
1124-
let esp_dev = root_dev.find_partition_of_esp()?;
1150+
// Locate ESP partition device by walking up to the root disk(s)
1151+
let root_dev = bootc_blockdev::list_dev_by_dir(&storage.physical_root)?;
1152+
let esp_dev = root_dev
1153+
.find_colocated_esps()?
1154+
.and_then(|mut v| {
1155+
if v.is_empty() {
1156+
None
1157+
} else {
1158+
Some(v.remove(0))
1159+
}
1160+
})
1161+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
11251162

11261163
(
11271164
sysroot,

crates/lib/src/store/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,18 @@ impl BootedStorage {
198198
}
199199
let composefs = Arc::new(composefs);
200200

201-
//TODO: this assumes a single ESP on the root device
202-
let root_dev =
203-
bootc_blockdev::list_dev_by_dir(&physical_root)?.require_single_root()?;
204-
let esp_dev = root_dev.find_partition_of_esp()?;
201+
// Locate ESP by walking up to the root disk(s)
202+
let root_dev = bootc_blockdev::list_dev_by_dir(&physical_root)?;
203+
let esp_dev = root_dev
204+
.find_colocated_esps()?
205+
.and_then(|mut v| {
206+
if v.is_empty() {
207+
None
208+
} else {
209+
Some(v.remove(0))
210+
}
211+
})
212+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
205213
let esp_mount = mount_esp(&esp_dev.path())?;
206214

207215
let boot_dir = match get_bootloader()? {

0 commit comments

Comments
 (0)