diff --git a/iridium_installer/backend/disk.py b/iridium_installer/backend/disk.py index c1fe32f..6f5916f 100644 --- a/iridium_installer/backend/disk.py +++ b/iridium_installer/backend/disk.py @@ -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)