]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto: do not add /sysusr/usr/ -> /sysroot/usr/ after switch-root
authorMike Yuan <me@yhndnzj.com>
Sat, 12 Apr 2025 12:50:46 +0000 (14:50 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 12 Apr 2025 14:33:22 +0000 (16:33 +0200)
Follow-up for 7852e301e0eb839adf4bf45aa41e39c0dfc03403

src/gpt-auto-generator/gpt-auto-generator.c

index 5274f81e300f3e9760983cb093d1bc90d702d621..73c4183f16c893169f2262b77a7690d7b33992a6 100644 (file)
@@ -918,8 +918,7 @@ static int add_usr_mount(void) {
         int r;
 
         /* /usr/ discovery must be enabled explicitly. */
-        if (arg_auto_usr == GPT_AUTO_ROOT_OFF ||
-            arg_auto_usr < 0)
+        if (arg_auto_usr <= 0)
                 return 0;
 
         /* We do not support the other gpt-auto modes for /usr/, but the parser should already have checked that. */
@@ -987,19 +986,22 @@ static int add_usr_mount(void) {
         if (r < 0)
                 return r;
 
-        log_debug("Synthesizing entry what=/sysusr/usr where=/sysroot/usr opts=bind");
-
-        return add_mount("usr-bind",
-                         "/sysusr/usr",
-                         "/sysroot/usr",
-                         /* fstype= */ NULL,
-                         /* flags= */ 0,
-                         "bind",
-                         "/usr/ Partition (Final)",
-                         in_initrd() ? SPECIAL_INITRD_FS_TARGET : SPECIAL_LOCAL_FS_TARGET);
-#else
-        return 0;
+        if (in_initrd()) {
+                log_debug("Synthesizing entry what=/sysusr/usr where=/sysroot/usr opts=bind");
+
+                r = add_mount("usr-bind",
+                              "/sysusr/usr",
+                              "/sysroot/usr",
+                              /* fstype= */ NULL,
+                              /* flags= */ 0,
+                              "bind",
+                              "/usr/ Partition (Final)",
+                              SPECIAL_INITRD_FS_TARGET);
+                if (r < 0)
+                        return r;
+        }
 #endif
+        return 0;
 }
 
 static int process_loader_partitions(DissectedPartition *esp, DissectedPartition *xbootldr) {