From 69d7f35ce4b642910575a3d973e713a27285663d Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 26 Jul 2023 12:10:43 +0800 Subject: [PATCH] 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. --- src/gpt-auto-generator/gpt-auto-generator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; } } -- 2.47.3