Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions crates/lib/src/bootloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ pub(crate) fn supports_bootupd(root: &Dir) -> Result<bool> {
Ok(r)
}

/// Install the bootloader via bootupd.
///
/// We pass `--filesystem` pointing at a block-backed mount so that bootupd
/// can resolve the backing device(s) itself via `lsblk`. In the bwrap path
/// we bind-mount the physical root at `/sysroot` to give `lsblk` a real
/// block-backed path; in the non-bwrap path the rootfs mount works directly.
#[context("Installing bootloader")]
pub(crate) fn install_via_bootupd(
device: &bootc_blockdev::Device,
_device: &bootc_blockdev::Device,
rootfs: &Utf8Path,
configopts: &crate::install::InstallConfigOpts,
deployment_path: Option<&str>,
Expand All @@ -91,8 +97,6 @@ pub(crate) fn install_via_bootupd(

println!("Installing bootloader via bootupd");

let device_path = device.path();

// Build the bootupctl arguments
let mut bootupd_args: Vec<&str> = vec!["backend", "install"];
if configopts.bootupd_skip_boot_uuid {
Expand All @@ -107,14 +111,17 @@ pub(crate) fn install_via_bootupd(
if let Some(ref opts) = bootupd_opts {
bootupd_args.extend(opts.iter().copied());
}
bootupd_args.extend(["--device", &device_path, rootfs_mount]);

bootupd_args.extend(["--filesystem", rootfs_mount]);
bootupd_args.push(rootfs_mount);

// Run inside a bwrap container. It takes care of mounting and creating
// the necessary API filesystems in the target deployment and acts as
// a nicer `chroot`.
if let Some(deploy) = deployment_path {
let target_root = rootfs.join(deploy);
let boot_path = rootfs.join("boot");
let rootfs_path = rootfs.to_path_buf();

tracing::debug!("Running bootupctl via bwrap in {}", target_root);

Expand All @@ -125,7 +132,10 @@ pub(crate) fn install_via_bootupd(
let cmd = BwrapCmd::new(&target_root)
// Bind mount /boot from the physical target root so bootupctl can find
// the boot partition and install the bootloader there
.bind(&boot_path, &"/boot");
.bind(&boot_path, &"/boot")
// Bind mount the physical root at /sysroot so bootupd can resolve
// backing block devices via lsblk for --filesystem
.bind(&rootfs_path, &"/sysroot");

// The $PATH in the bwrap env is not complete enough for some images
// so we inject a reasonnable default.
Expand Down
6 changes: 3 additions & 3 deletions crates/lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,7 @@ async fn install_to_filesystem_impl(
// Drop exclusive ownership since we're done with mutation
let rootfs = &*rootfs;

//TODO: loop over all parents devices?
match rootfs.device_info.pttype.as_deref() {
Some("dos") => crate::utils::medium_visibility_warning(
"Installing to `dos` format partitions is not recommended",
Expand Down Expand Up @@ -2545,9 +2546,8 @@ pub(crate) async fn install_to_filesystem(
// Find the real underlying backing device for the root. This is currently just required
// for GRUB (BIOS) and in the future zipl (I think).
let device_info = {
let dev =
bootc_blockdev::list_dev(Utf8Path::new(&inspect.source))?.require_single_root()?;
tracing::debug!("Backing device: {}", dev.path());
let dev = bootc_blockdev::list_dev(Utf8Path::new(&inspect.source))?;
tracing::debug!("Target filesystem backing device: {}", dev.path());
dev
};

Expand Down
7 changes: 7 additions & 0 deletions tmt/plans/integration.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,11 @@ execute:
how: fmf
test:
- /tmt/tests/tests/test-38-install-bootloader-none

/plan-39-multi-device-esp:
summary: Test multi-device ESP detection for to-existing-root
discover:
how: fmf
test:
- /tmt/tests/test-32-multi-device-esp
# END GENERATED PLANS
Loading
Loading