mirror of https://git.48k.eu/ogclient
utils: disk: revisit logging to find EFI partition
instead of Checking partition "Microsoft Basic Data"... Checking partition "EFI System"... show Searching EFI partition... EFI partition found at /dev/sda1 and refer to EFI partition consistently in logs.master
parent
9a553765b4
commit
9b317cf3e0
|
@ -58,19 +58,20 @@ def get_efi_partition(disknum, enforce_gpt):
|
||||||
"""
|
"""
|
||||||
disk_index = disknum - 1
|
disk_index = disknum - 1
|
||||||
if disk_index < 0 or disk_index >= len(get_disks()):
|
if disk_index < 0 or disk_index >= len(get_disks()):
|
||||||
raise OgError(f'Invalid disk number {disknum} when trying to find ESP, {len(get_disks())} disks available.')
|
raise OgError(f'Invalid disk number {disknum} when trying to find EFI partition, {len(get_disks())} disks available.')
|
||||||
|
|
||||||
disk = get_disks()[disk_index]
|
disk = get_disks()[disk_index]
|
||||||
cxt = fdisk.Context(f'/dev/{disk}')
|
cxt = fdisk.Context(f'/dev/{disk}')
|
||||||
|
|
||||||
if enforce_gpt and cxt.label == fdisk.FDISK_DISKLABEL_DOS:
|
if enforce_gpt and cxt.label == fdisk.FDISK_DISKLABEL_DOS:
|
||||||
raise OgError(f'Windows EFI System requires GPT partition scheme, but /dev/{disk} has DOS partition scheme')
|
raise OgError(f'Windows EFI partition requires GPT partition scheme, but /dev/{disk} has DOS partition scheme')
|
||||||
|
|
||||||
|
logging.info('Searching EFI partition...')
|
||||||
for pa in cxt.partitions:
|
for pa in cxt.partitions:
|
||||||
logging.info(f'Checking partition "{pa.type.name}"...')
|
|
||||||
if pa.type.name == 'EFI System':
|
if pa.type.name == 'EFI System':
|
||||||
|
logging.info(f'EFI partition found at /dev/{disk}')
|
||||||
return cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE), f'/dev/{disk}', pa.partno + 1
|
return cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE), f'/dev/{disk}', pa.partno + 1
|
||||||
raise OgError(f'Cannot find "EFI System" partition at /dev/{disk}')
|
raise OgError(f'Cannot find EFI partition at /dev/{disk}')
|
||||||
|
|
||||||
|
|
||||||
def get_partition_id(disk_index, part_index):
|
def get_partition_id(disk_index, part_index):
|
||||||
|
|
Loading…
Reference in New Issue