From 097360ca0abc7c5273d262ab763d87f474cf56b9 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Fri, 3 Jan 2020 17:32:51 -0700 Subject: [PATCH] Always ask GPT/MBR/Source when formatting a disk * This fixes cloning partitions when not creating a boot partiton --- scripts/wk/hw/ddrescue.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/wk/hw/ddrescue.py b/scripts/wk/hw/ddrescue.py index b3a599b0..bdf300bf 100644 --- a/scripts/wk/hw/ddrescue.py +++ b/scripts/wk/hw/ddrescue.py @@ -312,19 +312,19 @@ class State(): # New run, use new settings file settings['Needs Format'] = True offset = 0 + user_choice = std.choice( + ['G', 'M', 'S'], + 'Format clone using GPT, MBR, or match Source type?', + ) + if user_choice == 'G': + settings['Table Type'] = 'GPT' + elif user_choice == 'M': + settings['Table Type'] = 'MBR' + else: + # Match source type + settings['Table Type'] = get_table_type(self.source) if std.ask('Create an empty Windows boot partition on the clone?'): settings['Create Boot Partition'] = True - user_choice = std.choice( - ['G', 'M', 'S'], - 'Use GPT, MBR, or match Source type?', - ) - if user_choice == 'G': - settings['Table Type'] = 'GPT' - elif user_choice == 'M': - settings['Table Type'] = 'MBR' - else: - # Match source type - settings['Table Type'] = get_table_type(self.source) offset = 2 if settings['Table Type'] == 'GPT' else 1 # Add pairs @@ -1249,7 +1249,7 @@ def build_sfdisk_partition_line(table_type, dev_path, size, details): dest_type = source_type.upper() if not dest_type: # Assuming changing table types, set based on FS - if source_filesystem in cfg.ddrescue.PARTITION_TYPES[table_type]: + if source_filesystem in cfg.ddrescue.PARTITION_TYPES.get(table_type, {}): dest_type = cfg.ddrescue.PARTITION_TYPES[table_type][source_filesystem] line += f', type={dest_type}'