Skip to content

Commit 4ccc192

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

5 files changed

Lines changed: 463 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
@@ -1935,6 +1935,7 @@ async fn install_to_filesystem_impl(
19351935
// Drop exclusive ownership since we're done with mutation
19361936
let rootfs = &*rootfs;
19371937

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

tmt/plans/integration.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,11 @@ execute:
217217
how: fmf
218218
test:
219219
- /tmt/tests/tests/test-38-install-bootloader-none
220+
221+
/plan-39-multi-device-esp:
222+
summary: Test multi-device ESP detection for to-existing-root
223+
discover:
224+
how: fmf
225+
test:
226+
- /tmt/tests/test-32-multi-device-esp
220227
# END GENERATED PLANS

0 commit comments

Comments
 (0)