Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/partition.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-11-17 18:02:20 +0000
committerGitHub <noreply@github.com>2021-11-17 19:02:20 +0100
commit7d991ecb9f87f863e1e78ce7e2d06c4d2f9568db (patch)
tree09c93925204c14165ab1292c688e668c4a02f990 /archinstall/lib/disk/partition.py
parent5cc88a74ab79b245e9fbe0c4964a052088a22aea (diff)
Fixing broken encryption support in GRUB (#724)
* Added multiple `partprobe` calls and added a `.partprobe()` function on partitions, filesystem and blockdevice. * Adding retry attempts to all UUID related operations tied to the boot process * Tweaked logging for mounting and disk related operations * Removed potential SysCall exception disruptor causing exceptions to go by unnoticed * Increased the start position from 1MiB to 5MiB of /boot partition * Optimized the GRUB installation & config code * Improved Partition().uuid to never return None. Instead it will raise an exception if it can't get a PARTUUID within X retries with Y delay per attempt. * Increased sleep timer for partition uuid retrieval, because even with a 3 second sleep it wasn't long enough even on fast devices. * Make GRUB install to /dev/sda instead of /dev/sda1. * Added 10 retries for retreiving PARTUUID with a one second sleep. Instead of increasing the sleep simply add more retries until we find a good balance on slower disks.
Diffstat (limited to 'archinstall/lib/disk/partition.py')
-rw-r--r--archinstall/lib/disk/partition.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index 3630a6f4..faa0838f 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -147,14 +147,17 @@ class Partition:
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 i in range(10):
+ self.partprobe()
- partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
- if not partuuid_struct.exit_code == 0:
- raise DiskError(f"Could not get PARTUUID for {self.path}: {partuuid_struct}")
+ 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):
+ return partition_information.get('partuuid', None)
- for partition in json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']:
- return partition.get('partuuid', None)
- return None
+ time.sleep(1)
+
+ raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
@property
def encrypted(self):
@@ -177,6 +180,9 @@ class Partition:
# raise DiskError(f'Could not find appropriate parent for encrypted partition {self}')
return self.path
+ def partprobe(self):
+ SysCommand(f'bash -c "partprobe"')
+
def detect_inner_filesystem(self, password):
log(f'Trying to detect inner filesystem format on {self} (This might take a while)', level=logging.INFO)
from ..luks import luks2
@@ -315,9 +321,13 @@ class Partition:
try:
if options:
- SysCommand(f"/usr/bin/mount -o {options} {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount -o {options} {self.path} {target}")
else:
- SysCommand(f"/usr/bin/mount {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount {self.path} {target}")
+
+ # TODO: Should be redundant to check for exit_code
+ if mnt_handle.exit_code != 0:
+ raise DiskError(f"Could not mount {self.path} to {target} using options {options}")
except SysCallError as err:
raise err