switchroot: Be explicit about what could cause /sysroot to be ro
authorEric Curtin <ecurtin@redhat.com>
Thu, 21 Dec 2023 17:11:55 +0000 (17:11 +0000)
committerEric Curtin <ecurtin@redhat.com>
Thu, 21 Dec 2023 17:28:23 +0000 (17:28 +0000)
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 <ecurtin@redhat.com>
src/switchroot/ostree-mount-util.h
src/switchroot/ostree-prepare-root-static.c
src/switchroot/ostree-prepare-root.c

index eb79efdfbfb1fe2db7682df8d06c2ec764329d59..608528f35ac1d6f8f78f726722e24fc281537a55 100644 (file)
 #define _OSTREE_SYSROOT_READONLY_STAMP "/run/ostree-sysroot-ro.stamp"
 #define _OSTREE_COMPOSEFS_ROOT_STAMP "/run/ostree-composefs-root.stamp"
 
+#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"
+
 #define autofree __attribute__ ((cleanup (cleanup_free)))
 
 static inline int
index 4aaa46924681c71e46788275bc6536826547a3c0..ce3340f83d311f0295aa4c5b7d98eeab5e21ca58 100644 (file)
@@ -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)
index 8d0ab88e44527cc801bad78d609984b1b75201f6..1a0539e190d31fd13c6f3383512e41671a4dc70c 100644 (file)
@@ -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,