Reject ambiguous ESP filesystem UUIDs before root formatting

This commit is contained in:
Codex
2026-10-13 21:51:14 +03:00
parent 8512d1d10b
commit 87003e92c6
2 changed files with 36 additions and 0 deletions
+8
View File
@@ -118,6 +118,14 @@ def partition_plan(request, probe, topo):
fail('ESP must be an existing FAT GPT EFI System Partition')
if not UUID.fullmatch(esp_node.get('uuid') or ''):
fail('ESP filesystem UUID missing')
# fstab resolves the ESP by filesystem UUID. Copies on any surviving
# device are ambiguous even when their GPT partition identities differ.
# Root's old filesystem is replaced before fstab is written.
copies = [path for path, node in topo.nodes.items()
if path not in {root, esp}
and (node.get('uuid') or '').lower() == esp_node['uuid'].lower()]
if copies:
fail('ESP filesystem UUID is ambiguous on surviving devices: ' + ', '.join(sorted(copies)))
# Equal GPT IDs anywhere would make later PARTUUID recovery ambiguous.
ids = [n.get('partuuid', '').lower() for n in topo.nodes.values() if n.get('partuuid')]
if len(ids) != len(set(ids)):