Skip to content

Commit

Permalink
gpt-auto: don't mount ESP if there's an fstab entry for it
Browse files Browse the repository at this point in the history
Follow-up for systemd#28511

Fixes systemd#28550
  • Loading branch information
YHNdnzj committed Jul 29, 2023
1 parent 24c0078 commit 7893a54
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/gpt-auto-generator/gpt-auto-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 7893a54

Please sign in to comment.