summaryrefslogtreecommitdiffstats
path: root/src/partition
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-04-07 11:18:43 +0200
committerLennart Poettering <lennart@poettering.net>2021-04-20 18:53:15 +0200
commit8f47e32a3eefa1a366510b5d752875dd56bd7708 (patch)
tree3251222f7619ec7564cca43b73ab70b74eb9b8de /src/partition
parentrepart: try harder to find OS prefix (diff)
downloadsystemd-8f47e32a3eefa1a366510b5d752875dd56bd7708.tar.xz
systemd-8f47e32a3eefa1a366510b5d752875dd56bd7708.zip
repart: use /sysusr/ as --root= default in initrd, if mounted
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 976d1d538b..356fd9152c 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -4318,8 +4318,18 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_image && arg_root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported.");
else if (!arg_image && !arg_root && in_initrd()) {
- /* Default to operation on /sysroot when invoked in the initrd! */
- arg_root = strdup("/sysroot");
+
+ /* By default operate on /sysusr/ or /sysroot/ when invoked in the initrd. We prefer the
+ * former, if it is mounted, so that we have deterministic behaviour on systems where /usr/
+ * is vendor-supplied but the root fs formatted on first boot. */
+ r = path_is_mount_point("/sysusr/usr", NULL, 0);
+ if (r <= 0) {
+ if (r < 0 && r != -ENOENT)
+ log_debug_errno(r, "Unable to determine whether /sysusr/usr is a mount point, assuming it is not: %m");
+
+ arg_root = strdup("/sysroot");
+ } else
+ arg_root = strdup("/sysusr");
if (!arg_root)
return log_oom();
}