From c93482a8b943a593608d8bae7156e357ed0002d5 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 26 May 2022 18:46:10 +0200 Subject: Rework btrfs handling (#1234) * Restructuring btrfs.py into lib/btrfs/*.py * Reworking how BTRFS subvolumes get represented, and worked with. Subvolumes are now their own entity which can be used to access it's information, parents or mount location. * Added BtrfsSubvolume.partition and other stuff. * Reworking the way luks2().unlock and .format() returns device instances. They should now return BTRFSSubvolume where appropriate. * Fixed a missing import * Fixed an issue where mkfs.btrfs wouldn't trigger due to busy disk. * Fixing subvol mounting without creating a fake instance. * Added creation of mountpint for btrfs subvolume * Fixed root detection * Re-worked mounting into a queue system using frozen mounting calls using lambda * Removed old mount_subvolume() function * Removed get_subvolumes_from_findmnt() * Fixed Partition().subvolumes iteration * Adding .root to BtrfsSubvolume * Fixed issue in SysCommandWorker where log output would break and crash execution due to cmd being a string vs list * Changed return-value from MapperDev.mountpoint to pathlib.Path --- archinstall/lib/disk/mapperdev.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'archinstall/lib/disk/mapperdev.py') diff --git a/archinstall/lib/disk/mapperdev.py b/archinstall/lib/disk/mapperdev.py index 32e3ac9b..67230012 100644 --- a/archinstall/lib/disk/mapperdev.py +++ b/archinstall/lib/disk/mapperdev.py @@ -51,11 +51,11 @@ class MapperDev: raise ValueError(f"Could not convert {self.mappername} to a real dm-crypt device") @property - def mountpoint(self) -> Optional[str]: + def mountpoint(self) -> Optional[pathlib.Path]: try: data = json.loads(SysCommand(f"findmnt --json -R {self.path}").decode()) for filesystem in data['filesystems']: - return filesystem.get('target') + return pathlib.Path(filesystem.get('target')) except SysCallError as error: # Not mounted anywhere most likely @@ -76,8 +76,8 @@ class MapperDev: @property def subvolumes(self) -> Iterator['BtrfsSubvolume']: - from .btrfs import get_subvolumes_from_findmnt + from .btrfs import subvolume_info_from_path for mountpoint in self.mount_information: - for result in get_subvolumes_from_findmnt(mountpoint): - yield result \ No newline at end of file + if subvolume := subvolume_info_from_path(mountpoint): + yield subvolume \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 353c05318ce80b8eec32031c9e14b8471b458548 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 26 May 2022 19:53:24 +0200 Subject: Fix MapperDev.subvolumes (#1249) * Fixed a silent try/except, and MapperDev.subvolumes should now work. * MapperDev.subvolumes now properly sends a pathlib.Path. --- archinstall/lib/disk/btrfs/btrfs_helpers.py | 4 ++-- archinstall/lib/disk/mapperdev.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'archinstall/lib/disk/mapperdev.py') diff --git a/archinstall/lib/disk/btrfs/btrfs_helpers.py b/archinstall/lib/disk/btrfs/btrfs_helpers.py index d529478f..d577d82b 100644 --- a/archinstall/lib/disk/btrfs/btrfs_helpers.py +++ b/archinstall/lib/disk/btrfs/btrfs_helpers.py @@ -112,8 +112,8 @@ def subvolume_info_from_path(path :pathlib.Path) -> Optional[BtrfsSubvolume]: return BtrfsSubvolume(**{'full_path' : path, 'name' : subvolume_name, **result}) - except SysCallError: - pass + except SysCallError as error: + log(f"Could not retrieve subvolume information from {path}: {error}", level=logging.WARNING, fg="orange") return None diff --git a/archinstall/lib/disk/mapperdev.py b/archinstall/lib/disk/mapperdev.py index 67230012..913dbc13 100644 --- a/archinstall/lib/disk/mapperdev.py +++ b/archinstall/lib/disk/mapperdev.py @@ -77,7 +77,8 @@ class MapperDev: @property def subvolumes(self) -> Iterator['BtrfsSubvolume']: from .btrfs import subvolume_info_from_path - + for mountpoint in self.mount_information: - if subvolume := subvolume_info_from_path(mountpoint): - yield subvolume \ No newline at end of file + if target := mountpoint.get('target'): + if subvolume := subvolume_info_from_path(pathlib.Path(target)): + yield subvolume \ No newline at end of file -- cgit v1.2.3-70-g09d2