Skip to content

Conversation

@HuijingHei
Copy link
Member

@HuijingHei HuijingHei commented May 21, 2025

This is the preparation for #855.

The main target for this PR is: "efi: rewrite ensure_mounted_esp()", but find there are much to update consequently.


efi: rewrite ensure_mounted_esp()

Split into 2 parts:

  • get_mounted_esp() to get mounted point esp
  • mount_esp_device() to mount the passed esp device, return
    the mount point

Then in ensure_mounted_esp() call the above 2 functions:
firstly check if esp is already mounted, if not, mount the passed
esp device.


efi: update install() and update() according to split change


adopt_update: pass RootContext as parameter


efi: update validate() according to the split change

@openshift-ci
Copy link

openshift-ci bot commented May 21, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch 5 times, most recently from aacbb09 to d34bf3b Compare May 21, 2025 12:49
@HuijingHei HuijingHei changed the title Split ensure mounted esp efi: rewrite ensure_mounted_esp() May 21, 2025
@HuijingHei HuijingHei marked this pull request as ready for review May 21, 2025 13:12
@HuijingHei
Copy link
Member Author

Ready for review now, thanks!

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me overall, I just have some nits

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch 2 times, most recently from 9c9c6c7 to a85552e Compare May 23, 2025 14:32
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the cosa build is legitimately failing.

@HuijingHei
Copy link
Member Author

HuijingHei commented May 26, 2025

Seems the try_fold() iter all items without return at the first match, checking more fix this with return early.

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch 2 times, most recently from 3ff06fe to 950feab Compare May 26, 2025 12:04
@HuijingHei
Copy link
Member Author

/test test

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch from 950feab to ed38ae0 Compare May 26, 2025 13:23
Split into 2 parts:
- `get_mounted_esp()` to get mounted point esp
- `mount_esp_device()` to mount the passed esp device, return
the mount point

Then in `ensure_mounted_esp()` call the above 2 functions:
firstly check if esp is already mounted, if not, mount the passed
esp device.
@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch from ed38ae0 to 53ea47f Compare May 26, 2025 14:26
log::debug!("Found metadata {}", meta.version);
let srcdir_name = component_updatedirname(self);
let ft = crate::filetree::FileTree::new_from_dir(&src_root.sub_dir(&srcdir_name)?)?;
let destdir = &self.ensure_mounted_esp(Path::new(dest_root))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we keep calling this one to do the "mount if not mounted" logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. After change, the function ensure_mounted_esp() will check if esp is already mounted, else mount the passed esp device, return the mount point and append path /EFI.

For installation, during bootc install to-disk, the esp device is not mounted and will call get_esp_device() to get esp device via /dev/disk/by-partlabel, but when running cosa build, not sure if it would also call bootc, find that esp device is already mounted, and can not find esp device via /dev/disk/by-partlabel (do not why). Before I use esp_device = self.get_esp_device() before ensure_mounted_esp(), but cosa build failed.

Copy link
Member Author

@HuijingHei HuijingHei May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If failed get_esp_device() (via /dev/disk/by-partlabel), change to get_esp_partition(device) (via sfdisk).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to comment, use blockdev to find the partition, instead of partlabel.

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch 2 times, most recently from c17b92c to e0cfb73 Compare May 28, 2025 03:16
@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch 2 times, most recently from d2716e4 to 5998d92 Compare May 29, 2025 02:40
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - a few small suggestions

@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch from 5998d92 to e4b7a71 Compare May 29, 2025 14:50
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`
@HuijingHei HuijingHei force-pushed the split-ensure-mounted-esp branch from e4b7a71 to f6ef3d1 Compare May 29, 2025 14:54
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - merge when ready

@HuijingHei HuijingHei merged commit 50adce8 into coreos:main Jun 1, 2025
12 checks passed
@HuijingHei HuijingHei deleted the split-ensure-mounted-esp branch June 1, 2025 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants