Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Sep 4, 2023
1 parent 2c4149e commit 849c71b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
4 changes: 4 additions & 0 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion archinstall/lib/disk/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
34 changes: 29 additions & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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}" ' \
Expand Down

0 comments on commit 849c71b

Please sign in to comment.