Skip to content

Commit 37e4c0d

Browse files
committed
composefs: Write /boot fstab entry during install
The composefs install path was missing the /boot entry in /etc/fstab, causing the boot partition to not be mounted after reboot. This broke `bootc status` and `bootc upgrade` on systems with a separate /boot partition (e.g. `to-existing-root` installs). The ostree path writes this entry in install_container(), but the composefs path in setup_composefs_boot() did not. Write the /boot fstab entry to the deployment's state etc directory after write_composefs_state() creates it. Closes: #2120 Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent f450cf3 commit 37e4c0d

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,30 @@ pub(crate) async fn setup_composefs_boot(
13281328
)
13291329
.await?;
13301330

1331+
// Write the /boot entry to /etc/fstab in the deployment's state directory.
1332+
// This is needed so that systemd mounts the boot partition after reboot.
1333+
// The ostree path handles this in install_container(), but the composefs
1334+
// path was missing it.
1335+
if let Some(boot) = root_setup.boot.as_ref() {
1336+
if !boot.source.is_empty() {
1337+
let state_etc_path = root_setup
1338+
.physical_root_path
1339+
.join(crate::composefs_consts::STATE_DIR_RELATIVE)
1340+
.join(id.to_hex())
1341+
.join("etc");
1342+
let state_etc = Dir::open_ambient_dir(&state_etc_path, ambient_authority())
1343+
.with_context(|| format!("Opening {state_etc_path}"))?;
1344+
state_etc
1345+
.atomic_replace_with("fstab", |f| -> std::io::Result<_> {
1346+
use std::io::Write;
1347+
writeln!(f, "{}", boot.to_fstab())?;
1348+
Ok(())
1349+
})
1350+
.context("Writing /boot entry to etc/fstab")?;
1351+
tracing::debug!("Wrote /boot fstab entry: {}", boot.to_fstab());
1352+
}
1353+
}
1354+
13311355
Ok(())
13321356
}
13331357

crates/lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ pub(crate) struct RootSetup {
12721272
pub(crate) rootfs_uuid: Option<String>,
12731273
/// True if we should skip finalizing
12741274
skip_finalize: bool,
1275-
boot: Option<MountSpec>,
1275+
pub(crate) boot: Option<MountSpec>,
12761276
pub(crate) kargs: CmdlineOwned,
12771277
}
12781278

0 commit comments

Comments
 (0)