feat(partitioning): support fat32 and add validation for system partition name

This commit is contained in:
2026-02-03 19:53:51 +01:00
parent 11fca148be
commit 9f5bade34c
2 changed files with 58 additions and 4 deletions

View File

@@ -100,10 +100,11 @@ def mount_partitions(partition_info, mount_root="/mnt"):
logger.info(f"Partitions mounted at {mount_root}")
def create_partition(disk_device, size_mb, type_code="8300", name="Linux filesystem"):
def create_partition(disk_device, size_mb, type_code="8300", name="Linux filesystem", fstype=None):
"""
Creates a new partition on the disk.
Creates a new partition on the disk and formats it.
type_code: ef00 (EFI), 8200 (Swap), 8300 (Linux)
fstype: ext4, fat32, swap
"""
# Find next available partition number
res = run_command(["sgdisk", "-p", disk_device])
@@ -126,6 +127,20 @@ def create_partition(disk_device, size_mb, type_code="8300", name="Linux filesys
disk_device
])
run_command(["partprobe", disk_device])
# Wait for partition node
import time
time.sleep(1)
part_dev = get_partition_device(disk_device, next_num)
if fstype == "fat32":
run_command(["mkfs.vfat", "-F32", part_dev])
elif fstype == "ext4":
run_command(["mkfs.ext4", "-F", part_dev])
elif fstype == "swap":
run_command(["mkswap", part_dev])
return next_num
def delete_partition(disk_device, part_num):