Skip to content

install: attempt to use an already mounted ESP at the target#960

Merged
cgwalters merged 2 commits into
coreos:mainfrom
HuijingHei:fix-install-without-device
Jun 25, 2025
Merged

install: attempt to use an already mounted ESP at the target#960
cgwalters merged 2 commits into
coreos:mainfrom
HuijingHei:fix-install-without-device

Conversation

@HuijingHei
Copy link
Copy Markdown
Contributor

@HuijingHei HuijingHei commented Jun 24, 2025

Let's attempt to use an already mounted ESP at the target
dest_root if one is already mounted there in a known ESP location,
if failed, will fallback to mount ESP partition of the device.

See coreos/coreos-assembler#4161

@dustymabe
Copy link
Copy Markdown
Member

For the record, this problem isn't specific to metal4k images. It also happens on ARM (aarch64) where BIOS isn't an option and we only do EFI:

org.osbuild.bootupd: 8cdbb7572fe6ab1ee651a3b9434cd53ac65a741a1b32c031ce85c7bb470c3232 {
  "static-configs": true,
  "deployment": {
    "default": true
  }
}device/disk (org.osbuild.loopback): loop0 acquired (locked: False)mount/root (org.osbuild.xfs): mounting /dev/loop0p4 -> /home/jenkins/agent/workspace/debug-pod/cache/osbuild/store/tmp/buildroot-tmp-wmk3koya/mounts/
mount/boot (org.osbuild.ext4): mounting /dev/loop0p3 -> /home/jenkins/agent/workspace/debug-pod/cache/osbuild/store/tmp/buildroot-tmp-wmk3koya/mounts/bootmount/efi (org.osbuild.fat): mounting /dev/loop0p2 -> /home/jenkins/agent/workspace/debug-pod/cache/osbuild/store/tmp/buildroot-tmp-wmk3koya/mounts/boot/efi
Failed to open file "/sys/fs/selinux/checkreqprot": Read-only file systemerror: boot data installation failed: installing component EFI: Listing partitions of : Subprocess failed: ExitStatus(unix_wait_status(256))
sfdisk: cannot open : No such file or directory

Traceback (most recent call last):
  File "/run/osbuild/bin/org.osbuild.bootupd", line 82, in <module>
    r = main(_args, _args["options"])
  File "/run/osbuild/bin/org.osbuild.bootupd", line 75, in main
    subprocess.run(cmd, check=True)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['chroot', '/run/osbuild/mounts/ostree/deploy/fedora-coreos/deploy/806e2a45acf636237c21a97acd58c0e8e636669fe3c11bcc1be71b8704e8f9a5.0', '/usr/bin/bootupctl', 'backend', 'install', '--with-static-configs', '/run/osbuild/mounts']' returned non-zero exit status 1.

Comment thread src/efi.rs
Comment on lines +350 to +363
let destpath = if let Some(destdir) = self.get_mounted_esp(Path::new(dest_root))? {
destdir
} else {
// Using `blockdev` to find the partition instead of partlabel because
// we know the target install toplevel device already.
let esp_device = blockdev::get_esp_partition(device)?
.ok_or_else(|| anyhow::anyhow!("Failed to find ESP device"))?;
self.mount_esp_device(Path::new(dest_root), Path::new(&esp_device))?
};

let destd = &openat::Dir::open(destpath)
let destd = &openat::Dir::open(&destpath)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not 100% sure this is going to solve the problem in all cases. Do I understand correctly that device passed into this install() function will be None (i.e. device.is_empty() is true) if we aren't doing BIOS?

If that's the case then won't we run into this same problem IF the ESP isn't already mounted on platforms where BIOS isn't requested? i.e. if the ESP isn't already mounted and BIOS wasn't requested then we'll still fail. In the commit message for f6ef3d1 it mentions

During bootc install to-disk the esp device is not mounted

So I guess one way to test that theory would be to run a bootc install to-disk on say aarch64.

I kind of wish we coul just assume the ESP is already mounted in this function.

Copy link
Copy Markdown
Contributor Author

@HuijingHei HuijingHei Jun 25, 2025

Choose a reason for hiding this comment

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

Do I understand correctly that device passed into this install() function will be None (i.e. device.is_empty() is true) if we aren't doing BIOS?

Yes, we need the device to install BIOS, if without device on x64, will skip BIOS, see https://github.com/coreos/bootupd/blob/main/src/bootupd.rs#L88

If that's the case then won't we run into this same problem IF the ESP isn't already mounted on platforms where BIOS isn't requested? i.e. if the ESP isn't already mounted and BIOS wasn't requested then we'll still fail. In the commit message for f6ef3d1 it mentions

During bootc install to-disk the esp device is not mounted

So I guess one way to test that theory would be to run a bootc install to-disk on say aarch64.

On aarch64 is a little different as we do not include BIOS module, and bootc install to-disk calls bootupctl backend install --write-uuid --device /dev/loop0 /run/bootc/mounts/rootfs with device (see run logs)

I kind of wish we coul just assume the ESP is already mounted in this function.

Yes, as we do not have device and can not find esp and can not mount.

Copy link
Copy Markdown
Contributor Author

@HuijingHei HuijingHei Jun 25, 2025

Choose a reason for hiding this comment

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

if the ESP isn't already mounted and BIOS wasn't requested then we'll still fail.

Agree that will be a problem. We have the option --component to specify the target component, see https://github.com/coreos/bootupd/blob/main/src/cli/bootupd.rs#L66, maybe we should pass the device and specify --component EFI to skip BIOS when building metal4k image (for x64), but I think the workaround also works for that change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Include cosa osbuild metal4k in CI, and result is PASSED, IMU the workaround will fix the problem.

Comment thread src/efi.rs Outdated
@HuijingHei HuijingHei force-pushed the fix-install-without-device branch from d87d1e2 to 95c5ca1 Compare June 25, 2025 04:15
Let's attempt to use an already mounted ESP at the target
dest_root if one is already mounted there in a known ESP location,
if failed, will fallback to mount ESP partition of the device.

See coreos/coreos-assembler#4161
@HuijingHei HuijingHei force-pushed the fix-install-without-device branch from 95c5ca1 to 66877ef Compare June 25, 2025 06:20
@HuijingHei HuijingHei changed the title install: check mounted ESP firstly for efi install: attempt to use an already mounted ESP at the target Jun 25, 2025
Copy link
Copy Markdown
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

@cgwalters cgwalters merged commit 92a8fe2 into coreos:main Jun 25, 2025
12 checks passed
@HuijingHei HuijingHei deleted the fix-install-without-device branch June 25, 2025 12:52
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