diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py index 10974f54..fea9eb7e 100644 --- a/archinstall/lib/disk/device_handler.py +++ b/archinstall/lib/disk/device_handler.py @@ -695,28 +695,21 @@ class DeviceHandler(object): raise DiskError(f'Could not mount {dev_path}: {command}\n{err.message}') def umount(self, mountpoint: Path, recursive: bool = False): - try: - lsblk_info = get_lsblk_info(mountpoint) - except SysCallError as ex: - # this could happen if before partitioning the device contained 3 partitions - # and after partitioning only 2 partitions were created, then the modifications object - # will have a reference to /dev/sX3 which is being tried to umount here now - if 'not a block device' in ex.message: - return - raise ex + lsblk_info = get_lsblk_info(mountpoint) - if len(lsblk_info.mountpoints) > 0: - debug(f'Partition {mountpoint} is currently mounted at: {[str(m) for m in lsblk_info.mountpoints]}') + if not lsblk_info.mountpoints: + return - for mountpoint in lsblk_info.mountpoints: - debug(f'Unmounting mountpoint: {mountpoint}') + debug(f'Partition {mountpoint} is currently mounted at: {[str(m) for m in lsblk_info.mountpoints]}') - command = 'umount' + cmd = ['umount'] - if recursive: - command += ' -R' + if recursive: + cmd.append('-R') - SysCommand(f'{command} {mountpoint}') + for path in lsblk_info.mountpoints: + debug(f'Unmounting mountpoint: {path}') + SysCommand(cmd + [str(path)]) def detect_pre_mounted_mods(self, base_mountpoint: Path) -> List[DeviceModification]: part_mods: Dict[Path, List[PartitionModification]] = {}