diff --git a/lib/src/bootloader.rs b/lib/src/bootloader.rs index ed24dbd3f..810a2eb02 100644 --- a/lib/src/bootloader.rs +++ b/lib/src/bootloader.rs @@ -2,6 +2,7 @@ use anyhow::Result; use camino::Utf8Path; use fn_error_context::context; +use crate::blockdev::Device; use crate::task::Task; /// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel) @@ -9,18 +10,19 @@ pub(crate) const EFI_DIR: &str = "efi"; #[context("Installing bootloader")] pub(crate) fn install_via_bootupd( - device: &Utf8Path, + device: &Device, rootfs: &Utf8Path, configopts: &crate::install::InstallConfigOpts, ) -> Result<()> { let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv"); // bootc defaults to only targeting the platform boot method. let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]); + let devpath = device.path(); let args = ["backend", "install", "--write-uuid"] .into_iter() .chain(verbose) .chain(bootupd_opts.iter().copied().flatten()) - .chain(["--device", device.as_str(), rootfs.as_str()]); + .chain(["--device", devpath.as_str(), rootfs.as_str()]); Task::new("Running bootupctl to install bootloader", "bootupctl") .args(args) .verbose() diff --git a/lib/src/install.rs b/lib/src/install.rs index 4f3fa66d7..9c7acee21 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -823,7 +823,7 @@ fn require_skopeo_with_containers_storage() -> Result<()> { pub(crate) struct RootSetup { luks_device: Option, - device: Utf8PathBuf, + device_info: crate::blockdev::Device, rootfs: Utf8PathBuf, rootfs_fd: Dir, rootfs_uuid: Option, @@ -1240,7 +1240,11 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re .context("Writing aleph version")?; } - crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, &state.config_opts)?; + crate::bootloader::install_via_bootupd( + &rootfs.device_info, + &rootfs.rootfs, + &state.config_opts, + )?; tracing::debug!("Installed bootloader"); // Finalize mounted filesystems @@ -1594,6 +1598,7 @@ pub(crate) async fn install_to_filesystem( dev }; tracing::debug!("Backing device: {backing_device}"); + let device_info = crate::blockdev::list_dev(Utf8Path::new(&backing_device))?; let rootarg = format!("root={}", root_info.mount_spec); let mut boot = if let Some(spec) = fsopts.boot_mount_spec { @@ -1622,7 +1627,7 @@ pub(crate) async fn install_to_filesystem( matches!(fsopts.replace, Some(ReplaceMode::Alongside)) || fsopts.skip_finalize; let mut rootfs = RootSetup { luks_device: None, - device: backing_device.into(), + device_info, rootfs: fsopts.root_path, rootfs_fd, rootfs_uuid: inspect.uuid.clone(), diff --git a/lib/src/install/baseline.rs b/lib/src/install/baseline.rs index 0a9b85a5d..31abbe6ab 100644 --- a/lib/src/install/baseline.rs +++ b/lib/src/install/baseline.rs @@ -439,9 +439,10 @@ pub(crate) fn install_create_rootfs( BlockSetup::Direct => None, BlockSetup::Tpm2Luks => Some(luks_name.to_string()), }; + let device_info = crate::blockdev::list_dev(&devpath)?; Ok(RootSetup { luks_device, - device: devpath, + device_info, rootfs, rootfs_fd, rootfs_uuid: Some(root_uuid.to_string()),