From f0b38ce7bf832f7f643ba6eed195f2304d3674b5 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Thu, 21 Dec 2023 17:11:55 +0000 Subject: [PATCH] switchroot: Be explicit about what could cause /sysroot to be ro If you don't have rw in the kernel cmdline or have ro in it, often you hit this issue. This is just to be really explicit about that in the error messages so people can check. Signed-off-by: Eric Curtin --- src/libotcore/otcore.h | 4 ++++ src/switchroot/ostree-prepare-root-static.c | 3 +-- src/switchroot/ostree-prepare-root.c | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libotcore/otcore.h b/src/libotcore/otcore.h index 4d51398e6a..32a162dc1e 100644 --- a/src/libotcore/otcore.h +++ b/src/libotcore/otcore.h @@ -60,6 +60,10 @@ GKeyFile *otcore_load_config (int rootfs, const char *filename, GError **error); // The directory holding the root overlayfs #define OSTREE_DEPLOYMENT_ROOT_TRANSIENT_DIR "root-transient" +#define OTCORE_SYSROOT_NOT_WRITEABLE \ + "sysroot.readonly=true requires %s to be writable at this point, the cmdline should contain rw " \ + "but not ro, if that is not the case this is likely the issue" + // The name of the composefs metadata root #define OSTREE_COMPOSEFS_NAME ".ostree.cfs" // The temporary directory used for the EROFS mount; it's in the .private directory diff --git a/src/switchroot/ostree-prepare-root-static.c b/src/switchroot/ostree-prepare-root-static.c index 4aaa469246..ce3340f83d 100644 --- a/src/switchroot/ostree-prepare-root-static.c +++ b/src/switchroot/ostree-prepare-root-static.c @@ -229,8 +229,7 @@ main (int argc, char *argv[]) if (sysroot_readonly) { if (!sysroot_currently_writable) - errx (EXIT_FAILURE, "sysroot.readonly=true requires %s to be writable at this point", - root_arg); + errx (EXIT_FAILURE, OTCORE_SYSROOT_NOT_WRITEABLE, root_arg); /* Pass on the fact that we discovered a readonly sysroot to ostree-remount.service */ int fd = open (_OSTREE_SYSROOT_READONLY_STAMP, O_WRONLY | O_CREAT | O_CLOEXEC, 0644); if (fd < 0) diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 8d0ab88e44..1a0539e190 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -557,8 +557,7 @@ main (int argc, char *argv[]) if (sysroot_readonly) { if (!sysroot_currently_writable) - errx (EXIT_FAILURE, "sysroot.readonly=true requires %s to be writable at this point", - root_arg); + errx (EXIT_FAILURE, OTCORE_SYSROOT_NOT_WRITEABLE, root_arg); } /* Pass on the state for use by ostree-prepare-root */ g_variant_builder_add (&metadata_builder, "{sv}", OTCORE_RUN_BOOTED_KEY_SYSROOT_RO,