Skip to content

Commit d2716e4

Browse files
committed
efi: during installation using blockdev to find esp partition
instead of `partlabel` Copy Dusty's comment from https://github.com/coreos/bootupd/pull/932/files#r2112567301: During `bootc install to-disk` the esp device is not mounted but we can call `get_esp_device()` and it will find the device via the `/dev/disk/by-partlabel/` symlink. When running `cosa build` and building a disk image using `OSBuild` the EFI partitions is mounted but no udev `/dev/disk/by-partlabel/` symlinks exist because it's just a chroot and not a full linux environment. In that case fallback to using `blockdev` to find the partition. Even better, get rid of `self.get_esp_device()` altogether and just use `blockdev`
1 parent 53db0e9 commit d2716e4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/bootupd.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,21 @@ pub(crate) fn status() -> Result<Status> {
328328
// Process the remaining components not installed
329329
log::trace!("Remaining known components: {}", known_components.len());
330330
for (name, _) in known_components {
331-
// Only run `query_adopt_state()` is enough
332-
// When do adopt and update for each component, will check more
331+
// To determine if not-installed components can be adopted:
332+
//
333+
// `query_adopt_state()` checks for existing installation state,
334+
// such as a `version` in `/sysroot/.coreos-aleph-version.json`,
335+
// or the presence of `/ostree/deploy`.
336+
//
337+
// `component.query_adopt()` performs additional checks,
338+
// including hardware/device requirements.
339+
// For example, it will skip BIOS adoption if the system is booted via EFI
340+
// and lacks a BIOS_BOOT partition.
341+
//
342+
// Once a component is determined to be adoptable, it is added to the
343+
// adoptable list, and adoption proceeds automatically.
344+
//
345+
// Therefore, calling `query_adopt_state()` alone is sufficient.
333346
if let Some(adopt_ver) = crate::component::query_adopt_state()? {
334347
ret.adoptable.insert(name.to_string(), adopt_ver);
335348
} else {

src/efi.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub(crate) struct Efi {
6262

6363
impl Efi {
6464
// Get esp device via EFI partlabel
65+
#[allow(dead_code)]
6566
fn get_esp_device(&self) -> Option<PathBuf> {
6667
let esp_devices = [COREOS_ESP_PART_LABEL, ANACONDA_ESP_PART_LABEL]
6768
.into_iter()
@@ -321,11 +322,12 @@ impl Component for Efi {
321322
log::debug!("Found metadata {}", meta.version);
322323
let srcdir_name = component_updatedirname(self);
323324
let ft = crate::filetree::FileTree::new_from_dir(&src_root.sub_dir(&srcdir_name)?)?;
324-
// get esp device via /dev/disk/by-partlabel
325-
let esp_device = self
326-
.get_esp_device()
325+
326+
// Using `blockdev` to find the partition instead of partlabel
327+
let esp_device = blockdev::get_esp_partition(device)?
327328
.ok_or_else(|| anyhow::anyhow!("Failed to find ESP device"))?;
328-
let destpath = &self.ensure_mounted_esp(Path::new(dest_root), &esp_device)?;
329+
330+
let destpath = &self.ensure_mounted_esp(Path::new(dest_root), Path::new(&esp_device))?;
329331

330332
let destd = &openat::Dir::open(destpath)
331333
.with_context(|| format!("opening dest dir {}", destpath.display()))?;

0 commit comments

Comments
 (0)