mount: mount ESP at /boot alongside data runtimes

Add /boot root mount planning for VFAT ESP outputs, reuse the idempotent
mount logic to skip duplicates, and ensure /etc/fstab includes both
/var/mounts/{UUID} and the ESP when enabled.
This commit is contained in:
2025-10-10 10:11:58 +02:00
parent 285adeead4
commit cc126d77b4

View File

@@ -48,6 +48,7 @@ use std::path::Path;
use tracing::info;
const ROOT_BASE: &str = "/var/mounts";
const BOOT_TARGET: &str = "/boot";
const TARGET_SYSTEM: &str = "/var/cache/system";
const TARGET_ETC: &str = "/var/cache/etc";
const TARGET_MODULES: &str = "/var/cache/modules";
@@ -204,6 +205,16 @@ pub fn plan_mounts(fs_results: &[FsResult], _cfg: &Config) -> Result<MountPlan>
// Determine primary UUID
let primary_uuid = Some(data[0].uuid.clone());
// Optional ESP (VFAT) mount at /boot
if let Some(esp) = fs_results.iter().find(|r| matches!(r.kind, FsKind::Vfat)) {
root_mounts.push(PlannedMount {
uuid: esp.uuid.clone(),
target: BOOT_TARGET.to_string(),
fstype: fstype_str(esp.kind).to_string(),
options: "rw".to_string(),
});
}
// Subvol mounts only from primary FS
let primary = data[0];
let mut subvol_mounts: Vec<PlannedSubvolMount> = Vec::new();
@@ -452,7 +463,7 @@ pub fn maybe_write_fstab(mounts: &[MountResult], cfg: &Config) -> Result<()> {
// Partition mount results into runtime root mounts and final subvolume targets.
let mut root_entries: Vec<&MountResult> = mounts
.iter()
.filter(|m| m.target.starts_with(ROOT_BASE))
.filter(|m| m.target.starts_with(ROOT_BASE) || m.target == BOOT_TARGET)
.collect();
let wanted = [TARGET_ETC, TARGET_MODULES, TARGET_SYSTEM, TARGET_VM_META];
let mut subvol_entries: Vec<&MountResult> = mounts