Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-02-07 15:00:34 +0100
committerAnton Hvornum <anton@hvornum.se>2021-02-07 15:00:34 +0100
commit826119bb998789a8db8c2b96cfd2cd443b41bbae (patch)
tree66f33eea5ff250cc862e15ed1b560f2b5a3be21e /archinstall
parent7123da1c564bd88f9c3101c6e5e1773d0d2cdf62 (diff)
Added partition info on Partition() creation. This will help detect potential mountpoints as well as filesystem types if any
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/disk.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index aafb07a8..588054a0 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -116,11 +116,21 @@ class Partition():
part_id = os.path.basename(path)
self.path = path
self.part_id = part_id
- self.mountpoint = mountpoint
+ self.mountpoint = None
self.filesystem = filesystem # TODO: Autodetect if we're reusing a partition
self.size = size # TODO: Refresh?
self.encrypted = encrypted
+ if mountpoint:
+ self.mount(mountpoint)
+
+ if not self.mountpoint:
+ # As a last step, check if we've mounted outside of the script
+ partition_info = get_partition_info(self.path)
+ self.mountpoint = partition_info['target']
+ if partition_info['fstype'] != self.filesystem and filesystem:
+ raise DiskError(f"{self} was given a filesystem format, but a existing format was detected: {partition_info['fstype']}")
+
def __repr__(self, *args, **kwargs):
if self.encrypted:
return f'Partition(path={self.path}, real_device={self.real_device}, fs={self.filesystem}, mounted={self.mountpoint})'
@@ -311,3 +321,13 @@ def harddrive(size=None, model=None, fuzzy=False):
continue
return collection[drive]
+
+def get_partition_info(path):
+ output = b''.join(sys_command(f'/usr/bin/findmnt --json {path}'))
+ output = output.decode('UTF-8')
+ output = json.loads(output)
+ if 'filesystems' in output:
+ if len(output['filesystems']) > 1:
+ raise DiskError(f"Path '{path}' contains multiple mountpoints: {output['filesystems']}")
+
+ return output['filesystems'][0] \ No newline at end of file