Skip to content
Open
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
5 changes: 3 additions & 2 deletions crates/lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,16 @@ 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())?;
let bootfs = physical_root_path.join("boot");
// 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)?;
Expand Down
13 changes: 13 additions & 0 deletions crates/mount/src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading