Skip to content

Commit 347a6f4

Browse files
ckyrouacjmarrero
authored andcommitted
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> Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 460c2ef commit 347a6f4

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
@@ -548,8 +548,18 @@ pub(crate) fn setup_composefs_bls_boot(
548548
}
549549
}
550550

551-
// Locate ESP partition device
552-
let esp_part = root_setup.device_info.find_partition_of_esp()?;
551+
// Locate ESP partition device by walking up to the root disk(s)
552+
let esp_part = root_setup
553+
.device_info
554+
.find_colocated_esps()?
555+
.and_then(|mut v| {
556+
if v.is_empty() {
557+
None
558+
} else {
559+
Some(v.remove(0))
560+
}
561+
})
562+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
553563

554564
(
555565
root_setup.physical_root_path.clone(),
@@ -586,10 +596,18 @@ pub(crate) fn setup_composefs_bls_boot(
586596
.context("Failed to create 'composefs=' parameter")?;
587597
cmdline.add_or_modify(&param);
588598

589-
// Locate ESP partition device
590-
let root_dev =
591-
bootc_blockdev::list_dev_by_dir(&storage.physical_root)?.require_single_root()?;
592-
let esp_dev = root_dev.find_partition_of_esp()?;
599+
// Locate ESP partition device by walking up to the root disk(s)
600+
let root_dev = bootc_blockdev::list_dev_by_dir(&storage.physical_root)?;
601+
let esp_dev = root_dev
602+
.find_colocated_esps()?
603+
.and_then(|mut v| {
604+
if v.is_empty() {
605+
None
606+
} else {
607+
Some(v.remove(0))
608+
}
609+
})
610+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
593611

594612
(
595613
Utf8PathBuf::from("/sysroot"),
@@ -1097,7 +1115,18 @@ pub(crate) fn setup_composefs_uki_boot(
10971115
BootSetupType::Setup((root_setup, state, postfetch, ..)) => {
10981116
state.require_no_kargs_for_uki()?;
10991117

1100-
let esp_part = root_setup.device_info.find_partition_of_esp()?;
1118+
// Locate ESP partition device by walking up to the root disk(s)
1119+
let esp_part = root_setup
1120+
.device_info
1121+
.find_colocated_esps()?
1122+
.and_then(|mut v| {
1123+
if v.is_empty() {
1124+
None
1125+
} else {
1126+
Some(v.remove(0))
1127+
}
1128+
})
1129+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
11011130

11021131
(
11031132
root_setup.physical_root_path.clone(),
@@ -1112,10 +1141,18 @@ pub(crate) fn setup_composefs_uki_boot(
11121141
let sysroot = Utf8PathBuf::from("/sysroot"); // Still needed for root_path
11131142
let bootloader = host.require_composefs_booted()?.bootloader.clone();
11141143

1115-
// Locate ESP partition device
1116-
let root_dev =
1117-
bootc_blockdev::list_dev_by_dir(&storage.physical_root)?.require_single_root()?;
1118-
let esp_dev = root_dev.find_partition_of_esp()?;
1144+
// Locate ESP partition device by walking up to the root disk(s)
1145+
let root_dev = bootc_blockdev::list_dev_by_dir(&storage.physical_root)?;
1146+
let esp_dev = root_dev
1147+
.find_colocated_esps()?
1148+
.and_then(|mut v| {
1149+
if v.is_empty() {
1150+
None
1151+
} else {
1152+
Some(v.remove(0))
1153+
}
1154+
})
1155+
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
11191156

11201157
(
11211158
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)