From 849c71b470583590cdb2e56923a9f63b3b4ac61a Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Mon, 4 Sep 2023 21:40:56 +1000 Subject: [PATCH] Update --- archinstall/lib/disk/device_handler.py | 4 +++ archinstall/lib/disk/device_model.py | 1 - archinstall/lib/installer.py | 34 ++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py index d46275d1c3..7731bbc3c7 100644 --- a/archinstall/lib/disk/device_handler.py +++ b/archinstall/lib/disk/device_handler.py @@ -117,6 +117,10 @@ def find_partition(self, path: Path) -> Optional[_PartitionInfo]: return part return None + def get_parent_device_path(self, dev_path: Path) -> Path: + lsblk = get_lsblk_info(dev_path) + return Path(f'/dev/{lsblk.pkname}') + def get_uuid_for_path(self, path: Path) -> Optional[str]: partition = self.find_partition(path) return partition.partuuid if partition else None diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py index b1d07d9843..554910bcd2 100644 --- a/archinstall/lib/disk/device_model.py +++ b/archinstall/lib/disk/device_model.py @@ -1080,7 +1080,6 @@ def get_lsblk_info(dev_path: Union[Path, str]) -> LsblkInfo: def get_all_lsblk_info() -> List[LsblkInfo]: return _fetch_lsblk_info() - def get_lsblk_by_mountpoint(mountpoint: Path, as_prefix: bool = False) -> List[LsblkInfo]: def _check(infos: List[LsblkInfo]) -> List[LsblkInfo]: devices = [] diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 2de3041ed6..3b648ff305 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -880,27 +880,49 @@ def _add_grub_bootloader( self.pacman.strap('efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead? try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory={boot_partition.mountpoint} --bootloader-id=GRUB --removable', peek_output=True) + SysCommand( + f'/usr/bin/arch-chroot {self.target} grub-install ' + f'--debug ' + f'--target=x86_64-efi ' + f'--efi-directory={boot_partition.mountpoint} ' + f'--bootloader-id=GRUB ' + f'--removable', + peek_output=True + ) except SysCallError: try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --debug --target=x86_64-efi --efi-directory={boot_partition.mountpoint} --bootloader-id=GRUB --removable', peek_output=True) + SysCommand( + f'/usr/bin/arch-chroot {self.target} ' + f'grub-install ' + f'--debug ' + f'--target=x86_64-efi ' + f'--efi-directory={boot_partition.mountpoint} ' + f'--bootloader-id=GRUB ' + f'--removable', + peek_output=True + ) except SysCallError as err: raise DiskError(f"Could not install GRUB to {self.target}{boot_partition.mountpoint}: {err}") else: + parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path) + try: cmd = f'/usr/bin/arch-chroot' \ f' {self.target}' \ f' grub-install' \ f' --debug' \ f' --target=i386-pc' \ - f' --recheck {boot_partition.dev_path}' + f' --recheck {parent_dev_path}' SysCommand(cmd, peek_output=True) except SysCallError as err: raise DiskError(f"Failed to install GRUB boot on {boot_partition.dev_path}: {err}") try: - SysCommand(f'/usr/bin/arch-chroot {self.target} grub-mkconfig -o {boot_partition.mountpoint}/grub/grub.cfg') + SysCommand( + f'/usr/bin/arch-chroot {self.target} ' + f'grub-mkconfig -o {boot_partition.mountpoint}/grub/grub.cfg' + ) except SysCallError as err: raise DiskError(f"Could not configure GRUB: {err}") @@ -1055,8 +1077,10 @@ def _add_efistub_bootloader( debug(f'Root partition is an encrypted device identifying by PARTUUID: {root_partition.partuuid}') kernel_parameters.append(f'root=PARTUUID={root_partition.partuuid} rw rootfstype={root_partition.safe_fs_type.value} {" ".join(self._kernel_params)}') + parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path) + cmd = f'efibootmgr ' \ - f'--disk {boot_partition.dev_path} ' \ + f'--disk {parent_dev_path} ' \ f'--part {boot_partition.safe_dev_path} ' \ f'--create ' \ f'--label "{label}" ' \