]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto: skip mounting ESP if fstab for /boot/ uses the same device as discovered one 28511/head
authorMike Yuan <me@yhndnzj.com>
Wed, 26 Jul 2023 04:10:43 +0000 (12:10 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 26 Jul 2023 07:00:06 +0000 (15:00 +0800)
Follow-up for 6a488fa7cce8124fa885adf8a2f31363fe62f636

Currently, if an fstab entry for /boot/ exists, we'll skip to try /efi/
instead. However, if it's already using the same device as the discovered
one, we should not duplicate the mount.

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

index 08338bdd93dca9eb7b9f3dc7f56062a6b705dad1..840d3b6ed1dfcaa3476d9bf89ecef6c0e5ebec6b 100644 (file)
@@ -590,6 +590,16 @@ 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;
                 }
         }