diff --git a/crates/lib/src/install/baseline.rs b/crates/lib/src/install/baseline.rs index 8a32e98c9..cfd8878e1 100644 --- a/crates/lib/src/install/baseline.rs +++ b/crates/lib/src/install/baseline.rs @@ -484,7 +484,8 @@ pub(crate) fn install_create_rootfs( } } - bootc_mount::mount(&rootdev_path, &physical_root_path)?; + let fstype = &root_filesystem.to_string(); + bootc_mount::mount_typed(&rootdev_path, fstype, &physical_root_path)?; let target_rootfs = Dir::open_ambient_dir(&physical_root_path, cap_std::ambient_authority())?; crate::lsm::ensure_dir_labeled(&target_rootfs, "", Some("/".into()), 0o755.into(), sepolicy)?; let physical_root = Dir::open_ambient_dir(&physical_root_path, cap_std::ambient_authority())?; @@ -492,7 +493,7 @@ pub(crate) fn install_create_rootfs( // Create the underlying mount point directory, which should be labeled crate::lsm::ensure_dir_labeled(&target_rootfs, "boot", None, 0o755.into(), sepolicy)?; if let Some(bootdev) = bootdev { - bootc_mount::mount(&bootdev.path(), &bootfs)?; + bootc_mount::mount_typed(&bootdev.path(), fstype, &bootfs)?; } // And we want to label the root mount of /boot crate::lsm::ensure_dir_labeled(&target_rootfs, "boot", None, 0o755.into(), sepolicy)?; diff --git a/crates/mount/src/mount.rs b/crates/mount/src/mount.rs index 67eba4a68..c5f7eee16 100644 --- a/crates/mount/src/mount.rs +++ b/crates/mount/src/mount.rs @@ -145,6 +145,19 @@ pub fn mount(dev: &str, target: &Utf8Path) -> Result<()> { .run_inherited_with_cmd_context() } +/// Mount a device with an explicit filesystem type. +/// +/// This avoids relying on the `mount` utility's blkid auto-detection, +/// which can fail in certain container environments (e.g. when the +/// required filesystem kernel module is not yet loaded and the blkid +/// probe doesn't work, causing mount to fall back to iterating +/// `/etc/filesystems` and `/proc/filesystems`). +pub fn mount_typed(dev: &str, fstype: &str, target: &Utf8Path) -> Result<()> { + Command::new("mount") + .args(["-t", fstype, dev, target.as_str()]) + .run_inherited_with_cmd_context() +} + /// If the fsid of the passed path matches the fsid of the same path rooted /// at /proc/1/root, it is assumed that these are indeed the same mounted /// filesystem between container and host.