Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/disk/helpers.py')
-rw-r--r--archinstall/lib/disk/helpers.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
index e9f6bc10..26f701d2 100644
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -190,10 +190,26 @@ def get_partitions_in_use(mountpoint :str) -> List[Partition]:
output = json.loads(output)
for target in output.get('filesystems', []):
- mounts.append(Partition(target['source'], None, filesystem=target.get('fstype', None), mountpoint=target['target']))
+ # We need to create a BlockDevice() instead of 'None' here when creaiting Partition()
+ # Otherwise subsequent calls to .size etc will fail due to BlockDevice being None.
+
+ # So first, we create the partition without a BlockDevice and carefully only use it to get .real_device
+ # Note: doing print(partition) here will break because the above mentioned issue.
+ partition = Partition(target['source'], None, filesystem=target.get('fstype', None), mountpoint=target['target'])
+ partition = Partition(target['source'], partition.real_device, filesystem=target.get('fstype', None), mountpoint=target['target'])
+
+ # Once we have the real device (for instance /dev/nvme0n1p5) we can find the parent block device using
+ # (lsblk pkname lists both the partition and blockdevice, BD being the last entry)
+ result = SysCommand(f'lsblk -no pkname {partition.real_device}').decode().rstrip('\r\n').split('\r\n')[-1]
+ block_device = BlockDevice(f"/dev/{result}")
+
+ # Once we figured the block device out, we can properly create the partition object
+ partition = Partition(target['source'], block_device, filesystem=target.get('fstype', None), mountpoint=target['target'])
+
+ mounts.append(partition)
for child in target.get('children', []):
- mounts.append(Partition(child['source'], None, filesystem=child.get('fstype', None), mountpoint=child['target']))
+ mounts.append(Partition(child['source'], block_device, filesystem=child.get('fstype', None), mountpoint=child['target']))
return mounts