Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/device_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/disk/device_handler.py')
-rw-r--r--archinstall/lib/disk/device_handler.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index 7731bbc3..7cd79784 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -246,7 +246,7 @@ class DeviceHandler(object):
info(f'luks2 locking device: {dev_path}')
luks_handler.lock()
- def _validate(self, device_mod: DeviceModification):
+ def _validate_partitions(self, partitions: List[PartitionModification]):
checks = {
# verify that all partitions have a path set (which implies that they have been created)
lambda x: x.dev_path is None: ValueError('When formatting, all partitions must have a path set'),
@@ -257,7 +257,7 @@ class DeviceHandler(object):
}
for check, exc in checks.items():
- found = next(filter(check, device_mod.partitions), None)
+ found = next(filter(check, partitions), None)
if found is not None:
raise exc
@@ -270,12 +270,16 @@ class DeviceHandler(object):
Format can be given an overriding path, for instance /dev/null to test
the formatting functionality and in essence the support for the given filesystem.
"""
- self._validate(device_mod)
+
+ # don't touch existing partitions
+ filtered_part = [p for p in device_mod.partitions if not p.exists()]
+
+ self._validate_partitions(filtered_part)
# make sure all devices are unmounted
- self._umount_all_existing(device_mod)
+ self._umount_all_existing(device_mod.device_path)
- for part_mod in device_mod.partitions:
+ for part_mod in filtered_part:
# partition will be encrypted
if enc_conf is not None and part_mod in enc_conf.partitions:
self._perform_enc_formatting(
@@ -446,10 +450,10 @@ class DeviceHandler(object):
return luks_handler
- def _umount_all_existing(self, modification: DeviceModification):
- info(f'Unmounting all partitions: {modification.device_path}')
+ def _umount_all_existing(self, device_path: Path):
+ info(f'Unmounting all existing partitions: {device_path}')
- existing_partitions = self._devices[modification.device_path].partition_infos
+ existing_partitions = self._devices[device_path].partition_infos
for partition in existing_partitions:
debug(f'Unmounting: {partition.path}')
@@ -476,7 +480,7 @@ class DeviceHandler(object):
raise DiskError('Too many partitions on disk, MBR disks can only have 3 primary partitions')
# make sure all devices are unmounted
- self._umount_all_existing(modification)
+ self._umount_all_existing(modification.device_path)
# WARNING: the entire device will be wiped and all data lost
if modification.wipe:
@@ -489,13 +493,10 @@ class DeviceHandler(object):
info(f'Creating partitions: {modification.device_path}')
- # TODO sort by delete first
-
- for part_mod in modification.partitions:
- # don't touch existing partitions
- if part_mod.exists():
- continue
+ # don't touch existing partitions
+ filtered_part = [p for p in modification.partitions if not p.exists()]
+ for part_mod in filtered_part:
# if the entire disk got nuked then we don't have to delete
# any existing partitions anymore because they're all gone already
requires_delete = modification.wipe is False