]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto: don't mount ESP if there's an fstab entry for it 28564/head
authorMike Yuan <me@yhndnzj.com>
Sat, 29 Jul 2023 12:05:58 +0000 (20:05 +0800)
committerMike Yuan <me@yhndnzj.com>
Sat, 29 Jul 2023 12:06:41 +0000 (20:06 +0800)
Follow-up for #28511

Fixes #28550

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

index 4465038198b5a587455f74c9edd363bc867c30f8..585aaae2ede8e0fc227c67cfff481719395d97a4 100644 (file)
@@ -574,10 +574,17 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) {
                 return 0;
         }
 
+        /* Check if there's an existing fstab entry for ESP. If so, we just skip the gpt-auto logic. */
+        r = fstab_has_node(p->node);
+        if (r < 0)
+                return log_error_errno(r,
+                                       "Failed to check if fstab entry for device '%s' exists: %m", p->node);
+        if (r > 0)
+                return 0;
+
         /* If /boot/ is present, unused, and empty, we'll take that.
          * Otherwise, if /efi/ is unused and empty (or missing), we'll take that.
-         * Otherwise, we do nothing.
-         */
+         * Otherwise, we do nothing. */
         if (!has_xbootldr && slash_boot_exists()) {
                 r = slash_boot_in_fstab();
                 if (r < 0)
@@ -590,16 +597,6 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) {
                                 esp_path = "/boot";
                                 id = "boot";
                         }
-                } else {
-                        /* Check if the fstab entry for /boot/ is already the ESP. If so, we don't need to
-                         * check /efi/ or duplicate the mount there. */
-                        r = fstab_is_mount_point_full("/boot", p->node);
-                        if (r < 0)
-                                return log_error_errno(r,
-                                                       "Failed to check if fstab entry for /boot uses the same device as '%s': %m",
-                                                       p->node);
-                        if (r > 0)
-                                return 0;
                 }
         }