feat(partitioning): support fat32 and add validation for system partition name
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user