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 @@ -1939,6 +1939,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 @@ -2564,9 +2565,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
42 changes: 42 additions & 0 deletions hack/provision-derived.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,48 @@ resize_rootfs: false
CLOUDEOF
fi

# Temporary: update bootupd from @CoreOS/continuous copr until
# CentOS Stream 10 base image includes a version supporting --filesystem
. /usr/lib/os-release
case "${ID}-${VERSION_ID}" in
"centos-10"|"rhel-10."*)
case $ID in
fedora) copr_distro="fedora" ;;
*) copr_distro="centos-stream" ;;
esac
# Update bootc first from rhcontainerbot copr; the new bootupd
# requires a newer bootc than what ships in the base image.
cat >/etc/yum.repos.d/rhcontainerbot-bootc.repo <<REPOEOF
[copr:copr.fedorainfracloud.org:rhcontainerbot:bootc]
name=Copr repo for bootc owned by rhcontainerbot
baseurl=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/${copr_distro}-\$releasever-\$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
REPOEOF
dnf -y update bootc
rm -f /etc/yum.repos.d/rhcontainerbot-bootc.repo
cat >/etc/yum.repos.d/coreos-continuous.repo <<REPOEOF
[copr:copr.fedorainfracloud.org:group_CoreOS:continuous]
name=Copr repo for continuous owned by @CoreOS
baseurl=https://download.copr.fedorainfracloud.org/results/@CoreOS/continuous/${copr_distro}-\$releasever-\$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://download.copr.fedorainfracloud.org/results/@CoreOS/continuous/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
REPOEOF
dnf -y install bootupd-0.2.32.41.gb788553
rm -f /etc/yum.repos.d/coreos-continuous.repo
;;
esac

dnf clean all
# Stock extra cleaning of logs and caches in general (mostly dnf)
rm /var/log/* /var/cache /var/lib/{dnf,rpm-state,rhsm} -rf
Expand Down
7 changes: 7 additions & 0 deletions tmt/plans/integration.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,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-39-multi-device-esp
# END GENERATED PLANS
Loading
Loading