From: Mike Yuan Date: Wed, 26 Jul 2023 04:10:43 +0000 (+0800) Subject: gpt-auto: skip mounting ESP if fstab for /boot/ uses the same device as discovered one X-Git-Tag: v254~17^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69d7f35ce4b642910575a3d973e713a27285663d;p=thirdparty%2Fsystemd.git gpt-auto: skip mounting ESP if fstab for /boot/ uses the same device as discovered one 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. --- diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 08338bdd93d..840d3b6ed1d 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -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; } }