Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-12-16 09:00:10 +0000
committerGitHub <noreply@github.com>2021-12-16 09:00:10 +0000
commit7a018415862677c165494decc5d8ad9e06c65fb7 (patch)
tree0d216ce16b2e02f5270560621185db6ea8afee0d /archinstall/lib/disk
parent3c2e71b4bbfa2168afb54eb70aeecce9064c8435 (diff)
Changed lsblk to blkid where possible (#802)
* Swapped lsblk for blkid * Added a hefty sleep on partprobe() And added a TODO for the future
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/blockdevice.py3
-rw-r--r--archinstall/lib/disk/filesystem.py10
-rw-r--r--archinstall/lib/disk/helpers.py6
-rw-r--r--archinstall/lib/disk/partition.py16
4 files changed, 19 insertions, 16 deletions
diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py
index f8575de4..2be31375 100644
--- a/archinstall/lib/disk/blockdevice.py
+++ b/archinstall/lib/disk/blockdevice.py
@@ -150,8 +150,7 @@ class BlockDevice:
This is more reliable than relying on /dev/disk/by-partuuid as
it doesn't seam to be able to detect md raid partitions.
"""
- for partition in json.loads(SysCommand(f'lsblk -J -o+UUID {self.path}').decode('UTF-8'))['blockdevices']:
- return partition.get('uuid', None)
+ return SysCommand(f'blkid -s PTUUID -o value {self.path}').decode('UTF-8')
@property
def size(self):
diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py
index ac970b2a..72be7e70 100644
--- a/archinstall/lib/disk/filesystem.py
+++ b/archinstall/lib/disk/filesystem.py
@@ -36,6 +36,9 @@ class Filesystem:
def partuuid_to_index(self, uuid):
for i in range(storage['DISK_RETRY_ATTEMPTS']):
self.partprobe()
+ time.sleep(5)
+
+ # TODO: Convert to blkid (or something similar, but blkid doesn't support traversing to list sub-PARTUUIDs based on blockdevice path?)
output = json.loads(SysCommand(f"lsblk --json -o+PARTUUID {self.blockdevice.device}").decode('UTF-8'))
for device in output['blockdevices']:
@@ -127,7 +130,6 @@ class Filesystem:
def partprobe(self):
SysCommand(f'bash -c "partprobe"')
- time.sleep(1)
def raw_parted(self, string: str):
if (cmd_handle := SysCommand(f'/usr/bin/parted -s {string}')).exit_code != 0:
@@ -205,5 +207,9 @@ class Filesystem:
SysCommand(f'bash -c "umount {device}?"')
except:
pass
+
+ self.partprobe()
+ worked = self.raw_parted(f'{device} mklabel {disk_label}').exit_code == 0
self.partprobe()
- return self.raw_parted(f'{device} mklabel {disk_label}').exit_code == 0
+
+ return worked
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
index 9442f1b6..8e6a79e4 100644
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -214,10 +214,14 @@ def find_partition_by_mountpoint(block_devices, relative_mountpoint :str):
def partprobe():
SysCommand(f'bash -c "partprobe"')
+ time.sleep(5)
def convert_device_to_uuid(path :str) -> str:
for i in range(storage['DISK_RETRY_ATTEMPTS']):
partprobe()
+
+ # TODO: Convert lsblk to blkid
+ # (lsblk supports BlockDev and Partition UUID grabbing, blkid requires you to pick PTUUID and PARTUUID)
output = json.loads(SysCommand(f"lsblk --json -o+UUID {path}").decode('UTF-8'))
for device in output['blockdevices']:
@@ -226,4 +230,4 @@ def convert_device_to_uuid(path :str) -> str:
time.sleep(storage['DISK_TIMEOUTS'])
- raise DiskError(f"Could not retrieve the UUID of {path} within a timely manner.") \ No newline at end of file
+ raise DiskError(f"Could not retrieve the UUID of {path} within a timely manner.")
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index 0da991ef..b696d9dd 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -159,15 +159,13 @@ class Partition:
for i in range(storage['DISK_RETRY_ATTEMPTS']):
self.partprobe()
- partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
- if partuuid_struct.exit_code == 0:
- if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
- if partuuid := partition_information.get('partuuid', None):
- return partuuid
+ partuuid = self._safe_uuid
+ if partuuid:
+ return partuuid
time.sleep(storage['DISK_TIMEOUTS'])
- raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
+ raise DiskError(f"Could not get PARTUUID for {self.path} using 'blkid -s PARTUUID -o value {self.path}'")
@property
def _safe_uuid(self) -> Optional[str]:
@@ -178,11 +176,7 @@ class Partition:
"""
self.partprobe()
- partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
- if partuuid_struct.exit_code == 0:
- if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
- if partuuid := partition_information.get('partuuid', None):
- return partuuid
+ return SysCommand(f'blkid -s PARTUUID -o value {self.path}').decode('UTF-8').strip()
@property
def encrypted(self):