fix(backend): improve partition creation robustness and formatting

This commit is contained in:
2026-02-03 20:03:24 +01:00
parent 9f5bade34c
commit 7371da2451

View File

@@ -119,18 +119,24 @@ def create_partition(disk_device, size_mb, type_code="8300", name="Linux filesys
while next_num in existing_nums:
next_num += 1
# Use -g (mbrtogpt) to ensure we can work on the disk if it was MBR
run_command([
"sgdisk",
"sgdisk",
"-g",
"-n", f"{next_num}:0:+{size_mb}M",
"-t", f"{next_num}:{type_code}",
"-c", f"{next_num}:{name}",
disk_device
])
run_command(["partprobe", disk_device])
# Wait for partition node
import time
time.sleep(1)
# Wait for partition node to appear
try:
run_command(["udevadm", "settle", "--timeout=5"])
except Exception:
import time
time.sleep(2)
part_dev = get_partition_device(disk_device, next_num)