Skip to content

Commit 541691d

Browse files
committed
install: Enable installing to devices with multiple parents
Signed-off-by: ckyrouac <ckyrouac@redhat.com>
1 parent eebb1fe commit 541691d

6 files changed

Lines changed: 504 additions & 8 deletions

File tree

crates/lib/src/bootloader.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ pub(crate) fn supports_bootupd(root: &Dir) -> Result<bool> {
6767
Ok(r)
6868
}
6969

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

9298
println!("Installing bootloader via bootupd");
9399

94-
let device_path = device.path();
95-
96100
// Build the bootupctl arguments
97101
let mut bootupd_args: Vec<&str> = vec!["backend", "install"];
98102
if configopts.bootupd_skip_boot_uuid {
@@ -107,14 +111,17 @@ pub(crate) fn install_via_bootupd(
107111
if let Some(ref opts) = bootupd_opts {
108112
bootupd_args.extend(opts.iter().copied());
109113
}
110-
bootupd_args.extend(["--device", &device_path, rootfs_mount]);
114+
115+
bootupd_args.extend(["--filesystem", rootfs_mount]);
116+
bootupd_args.push(rootfs_mount);
111117

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

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

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

130140
// The $PATH in the bwrap env is not complete enough for some images
131141
// so we inject a reasonnable default.

crates/lib/src/install.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,7 @@ async fn install_to_filesystem_impl(
19391939
// Drop exclusive ownership since we're done with mutation
19401940
let rootfs = &*rootfs;
19411941

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

hack/provision-derived.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,48 @@ resize_rootfs: false
6969
CLOUDEOF
7070
fi
7171

72+
# Temporary: update bootupd from @CoreOS/continuous copr until
73+
# CentOS Stream 10 base image includes a version supporting --filesystem
74+
. /usr/lib/os-release
75+
case "${ID}-${VERSION_ID}" in
76+
"centos-10"|"rhel-10."*)
77+
case $ID in
78+
fedora) copr_distro="fedora" ;;
79+
*) copr_distro="centos-stream" ;;
80+
esac
81+
# Update bootc first from rhcontainerbot copr; the new bootupd
82+
# requires a newer bootc than what ships in the base image.
83+
cat >/etc/yum.repos.d/rhcontainerbot-bootc.repo <<REPOEOF
84+
[copr:copr.fedorainfracloud.org:rhcontainerbot:bootc]
85+
name=Copr repo for bootc owned by rhcontainerbot
86+
baseurl=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/${copr_distro}-\$releasever-\$basearch/
87+
type=rpm-md
88+
skip_if_unavailable=True
89+
gpgcheck=1
90+
gpgkey=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/pubkey.gpg
91+
repo_gpgcheck=0
92+
enabled=1
93+
enabled_metadata=1
94+
REPOEOF
95+
dnf -y update bootc
96+
rm -f /etc/yum.repos.d/rhcontainerbot-bootc.repo
97+
cat >/etc/yum.repos.d/coreos-continuous.repo <<REPOEOF
98+
[copr:copr.fedorainfracloud.org:group_CoreOS:continuous]
99+
name=Copr repo for continuous owned by @CoreOS
100+
baseurl=https://download.copr.fedorainfracloud.org/results/@CoreOS/continuous/${copr_distro}-\$releasever-\$basearch/
101+
type=rpm-md
102+
skip_if_unavailable=True
103+
gpgcheck=1
104+
gpgkey=https://download.copr.fedorainfracloud.org/results/@CoreOS/continuous/pubkey.gpg
105+
repo_gpgcheck=0
106+
enabled=1
107+
enabled_metadata=1
108+
REPOEOF
109+
dnf -y install bootupd-0.2.32.41.gb788553
110+
rm -f /etc/yum.repos.d/coreos-continuous.repo
111+
;;
112+
esac
113+
72114
dnf clean all
73115
# Stock extra cleaning of logs and caches in general (mostly dnf)
74116
rm /var/log/* /var/cache /var/lib/{dnf,rpm-state,rhsm} -rf

tmt/plans/integration.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,11 @@ execute:
222222
how: fmf
223223
test:
224224
- /tmt/tests/tests/test-38-install-bootloader-none
225+
226+
/plan-39-multi-device-esp:
227+
summary: Test multi-device ESP detection for to-existing-root
228+
discover:
229+
how: fmf
230+
test:
231+
- /tmt/tests/test-39-multi-device-esp
225232
# END GENERATED PLANS

0 commit comments

Comments
 (0)