From 57bad26553166d6c1bfa81576089a29d56c970a7 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Jul 2021 15:10:23 +0200 Subject: 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). --- archinstall/lib/disk.py | 2 +- archinstall/lib/user_interaction.py | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index e804e0eb..d6f6ebde 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -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': diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 91456626..9f4ddc6d 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -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): -- cgit v1.2.3-54-g00ecf