Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-05-10 19:21:05 +0200
committerAnton Hvornum <anton@hvornum.se>2021-05-10 19:21:05 +0200
commitdd52bfb3a7f6f7a150e46f7c99d538e26de60276 (patch)
treebab058d1ebd323fccf45bd5acf8d324b894ea529 /archinstall/lib/disk.py
parent4aaaa3208bedc110cef4b4545031e8e43103161a (diff)
Tested the workflow, and it works pretty decent. There's some kinks to work out. Added BlockDevice().size as well.
Diffstat (limited to 'archinstall/lib/disk.py')
-rw-r--r--archinstall/lib/disk.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index dd704261..ab3560a9 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -152,6 +152,16 @@ class BlockDevice():
for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']:
return partition.get('uuid', None)
+ @property
+ def size(self):
+ output = b"".join(sys_command(f"lsblk --json -o+SIZE {self.path}"))
+ output = json.loads(output.decode('UTF-8'))
+
+ for device in output['blockdevices']:
+ assert device['size'][-1] == 'G' # Make sure we're counting in Gigabytes, otherwise the next logic fails.
+
+ return float(device['size'][:-1])
+
def has_partitions(self):
return len(self.partitions)