From 7d991ecb9f87f863e1e78ce7e2d06c4d2f9568db Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 17 Nov 2021 18:02:20 +0000 Subject: 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. --- archinstall/lib/disk/filesystem.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'archinstall/lib/disk/filesystem.py') diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 2eb1864d..fe7be498 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -33,12 +33,18 @@ class Filesystem: return True def partuuid_to_index(self, uuid): - output = json.loads(SysCommand(f"lsblk --json -o+PARTUUID {self.blockdevice.device}").decode('UTF-8')) + for i in range(10): + self.partprobe() + output = json.loads(SysCommand(f"lsblk --json -o+PARTUUID {self.blockdevice.device}").decode('UTF-8')) + + for device in output['blockdevices']: + for index, partition in enumerate(device['children']): + if (partuuid := partition.get('partuuid', None)) and partuuid.lower() == uuid: + return index + + time.sleep(1) - for device in output['blockdevices']: - for index, partition in enumerate(device['children']): - if partition['partuuid'].lower() == uuid: - return index + raise DiskError(f"Failed to convert PARTUUID {uuid} to a partition index number on blockdevice {self.blockdevice.device}") def load_layout(self, layout :dict): from ..luks import luks2 @@ -105,6 +111,7 @@ class Filesystem: partition['device_instance'].format(partition['filesystem']['format'], options=partition.get('options', [])) if partition.get('boot', False): + log(f"Marking partition {partition['device_instance']} as bootable.") self.set(self.partuuid_to_index(partition['device_instance'].uuid), 'boot on') def find_partition(self, mountpoint): -- cgit v1.2.3-70-g09d2