From 7e362cc8e58e97c178a55ce522556e569d8bb103 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Mon, 29 Jan 2024 21:52:52 +1100 Subject: [PATCH] Fix bug with LuksOnLvm and Btrfs --- archinstall/lib/disk/device_handler.py | 41 +++++--------------------- archinstall/lib/disk/filesystem.py | 2 +- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py index e0d023d1e8..b58f937336 100644 --- a/archinstall/lib/disk/device_handler.py +++ b/archinstall/lib/disk/device_handler.py @@ -19,7 +19,7 @@ FilesystemType, Unit, PartitionTable, ModificationStatus, get_lsblk_info, LsblkInfo, _BtrfsSubvolumeInfo, get_all_lsblk_info, DiskEncryption, LvmVolumeGroup, LvmVolume, Size, LvmGroupInfo, - SectorSize, LvmVolumeInfo, LvmPVInfo + SectorSize, LvmVolumeInfo, LvmPVInfo, SubvolumeModification ) from ..exceptions import DiskError, UnknownFilesystemFormat @@ -537,38 +537,17 @@ def fetch_part_info(self, path: Path) -> LsblkInfo: def create_lvm_btrfs_subvolumes( self, - lv: LvmVolume, - enc_conf: Optional['DiskEncryption'] = None + path: Path, + btrfs_subvols: List[SubvolumeModification] ): - info(f'Creating subvolumes: {lv.safe_dev_path}') + info(f'Creating subvolumes: {path}') - luks_handler = None + self.mount(path, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True) - # # unlock the partition first if it's encrypted - # if enc_conf is not None and lv in enc_conf.partitions: - # if not part_mod.mapper_name: - # raise ValueError('No device path specified for modification') - # - # luks_handler = self.unlock_luks2_dev( - # part_mod.safe_dev_path, - # part_mod.mapper_name, - # enc_conf.encryption_password - # ) - # - # if not luks_handler.mapper_dev: - # raise DiskError('Failed to unlock luks device') - # - # self.mount(luks_handler.mapper_dev, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True) - # else: - self.mount(lv.safe_dev_path, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True) - - for sub_vol in lv.btrfs_subvols: + for sub_vol in btrfs_subvols: debug(f'Creating subvolume: {sub_vol.name}') - if luks_handler is not None: - subvol_path = self._TMP_BTRFS_MOUNT / sub_vol.name - else: - subvol_path = self._TMP_BTRFS_MOUNT / sub_vol.name + subvol_path = self._TMP_BTRFS_MOUNT / sub_vol.name SysCommand(f"btrfs subvolume create {subvol_path}") @@ -584,11 +563,7 @@ def create_lvm_btrfs_subvolumes( except SysCallError as err: raise DiskError(f'Could not set compress attribute at {subvol_path}: {err}') - if luks_handler is not None and luks_handler.mapper_dev is not None: - self.umount(luks_handler.mapper_dev) - luks_handler.lock() - else: - self.umount(lv.safe_dev_path) + self.umount(path) def create_btrfs_volumes( self, diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 072be600e5..f0af24c010 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -242,7 +242,7 @@ def _format_lvm_vols( device_handler.format(vol.fs_type, path) if vol.fs_type == FilesystemType.Btrfs: - device_handler.create_lvm_btrfs_subvolumes(vol, enc_conf=self._enc_config) + device_handler.create_lvm_btrfs_subvolumes(path, vol.btrfs_subvols) def _lvm_create_pvs( self,