Added options to mark/unmark partitions for formatting (useful when re-using partitions, and fine tune which data to save and which to wipe). Setting a desired filesystem for a partition (both new ones and the ones being re-used).
This commit is contained in:
parent
51f2eca60e
commit
57bad26553
|
|
@ -788,7 +788,7 @@ class Filesystem:
|
|||
else:
|
||||
raise ValueError(f"{self}.load_layout() doesn't know how to continue without a new partition definition or a UUID ({partition.get('PARTUUID')}) on the device ({self.blockdevice.get_partition(uuid=partition_uuid)}).")
|
||||
|
||||
if partition.get('filesystem', {}).get('format', None):
|
||||
if partition.get('filesystem', {}).get('format', False):
|
||||
if partition.get('encrypted', False):
|
||||
if not partition.get('password'):
|
||||
if storage['arguments'] == 'silent':
|
||||
|
|
|
|||
|
|
@ -614,8 +614,10 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
|
|||
"Delete a partition" if len(block_device_struct) else "",
|
||||
"Clear/Delete all partitions" if len(block_device_struct) else "",
|
||||
"Assign mount-point for a partition" if len(block_device_struct) else "",
|
||||
"Mark/Unmark a partition to be formatted (wipes data)" if len(block_device_struct) else "",
|
||||
"Mark/Unmark a partition as encrypted" if len(block_device_struct) else "",
|
||||
"Mark/Unmark a partition as bootable (automatic for /boot)" if len(block_device_struct) else ""
|
||||
"Mark/Unmark a partition as bootable (automatic for /boot)" if len(block_device_struct) else "",
|
||||
"Set desired filesystem for a partition" if len(block_device_struct) else "",
|
||||
]
|
||||
|
||||
# Print current partition layout:
|
||||
|
|
@ -697,6 +699,11 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
|
|||
else:
|
||||
del(block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['mountpoint'])
|
||||
|
||||
elif task == "Mark/Unmark a partition to be formatted (wipes data)":
|
||||
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to mask for formatting: ', options_output=False)):
|
||||
# Negate the current encryption marking
|
||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['format'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('format', False)
|
||||
|
||||
elif task == "Mark/Unmark a partition as encrypted":
|
||||
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to mark as encrypted: ', options_output=False)):
|
||||
# Negate the current encryption marking
|
||||
|
|
@ -706,6 +713,20 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
|
|||
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to mark as bootable: ', options_output=False)):
|
||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('boot', False)
|
||||
|
||||
elif task == "Set desired filesystem for a partition":
|
||||
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to set a filesystem on: ', options_output=False)):
|
||||
if not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('filesystem', None):
|
||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem'] = {}
|
||||
|
||||
while True:
|
||||
fstype = input("Enter a desired filesystem type for the partition: ").strip()
|
||||
if not valid_fs_type(fstype):
|
||||
log(f"Desired filesystem {fstype} is not a valid filesystem.", level=logging.ERROR, fg="red")
|
||||
continue
|
||||
break
|
||||
|
||||
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem']['format'] = fstype
|
||||
|
||||
return block_device_struct
|
||||
|
||||
def select_individual_blockdevice_usage(block_devices :list):
|
||||
|
|
|
|||
Loading…
Reference in New Issue