fix(backend): improve partition creation robustness and formatting
This commit is contained in:
@@ -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",
|
||||
"-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
|
||||
# Wait for partition node to appear
|
||||
try:
|
||||
run_command(["udevadm", "settle", "--timeout=5"])
|
||||
except Exception:
|
||||
import time
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
|
||||
part_dev = get_partition_device(disk_device, next_num)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user