From 72e3131ace9617e1c523fe0dad7a0be3376d4a99 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Fri, 3 Jul 2026 02:31:35 +0000 Subject: [PATCH] initramfs: tolerate pre-existing /run/systemd/volatile-root symlink ostree-prepare-root is growing the same gpt-auto workaround for composefs roots (creating the /run/systemd/volatile-root symlink so systemd's blockdev_get_root() can resolve the backing device, see https://github.com/systemd/systemd/issues/35017), proposed in https://github.com/ostreedev/ostree/pull/3608. It runs before bootc-root-setup.service, so once that lands the symlink already exists by the time gpt_workaround() runs, and the unconditional symlink() call makes the service fail. Both creators point the symlink at the /dev/block/MAJ:MIN alias of the same physical root device, so simply ignore EEXIST, matching how ensure_dir() handles already-existing directories. Signed-off-by: Ricardo Salveti --- crates/initramfs/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/initramfs/src/lib.rs b/crates/initramfs/src/lib.rs index f01b7fc43..c734f547c 100644 --- a/crates/initramfs/src/lib.rs +++ b/crates/initramfs/src/lib.rs @@ -419,8 +419,13 @@ pub fn gpt_workaround() -> Result<()> { major(rootdev.st_rdev), minor(rootdev.st_rdev) ); - symlink(target, "/run/systemd/volatile-root")?; - Ok(()) + // Handle the case where the symlink was already created before bootc + // runs, e.g. by ostree-prepare-root + // (https://github.com/ostreedev/ostree/pull/3608). + match symlink(target, "/run/systemd/volatile-root") { + Ok(()) | Err(Errno::EXIST) => Ok(()), + Err(err) => Err(err).context("Creating /run/systemd/volatile-root"), + } } /// Sets up /sysroot for switch-root