Skip to content

Commit 921526f

Browse files
committed
Create proper EFI boot menu entry for Limine
1 parent aa44474 commit 921526f

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

archinstall/lib/installer.py

+36-6
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ def _add_limine_bootloader(
12351235
root: PartitionModification | LvmVolume,
12361236
uki_enabled: bool = False
12371237
) -> None:
1238-
debug('Installing limine bootloader')
1238+
debug('Installing Limine bootloader')
12391239

12401240
self.pacman.strap('limine')
12411241

@@ -1244,7 +1244,11 @@ def _add_limine_bootloader(
12441244
limine_path = self.target / 'usr' / 'share' / 'limine'
12451245
hook_command = None
12461246

1247+
parent_dev_path = device_handler.get_parent_device_path(boot_partition.safe_dev_path)
1248+
12471249
if SysInfo.has_uefi():
1250+
self.pacman.strap('efibootmgr')
1251+
12481252
if not efi_partition:
12491253
raise ValueError('Could not detect efi partition')
12501254
elif not efi_partition.mountpoint:
@@ -1253,7 +1257,7 @@ def _add_limine_bootloader(
12531257
info(f"Limine EFI partition: {efi_partition.dev_path}")
12541258

12551259
try:
1256-
efi_dir_path = self.target / efi_partition.mountpoint.relative_to('/') / 'EFI' / 'BOOT'
1260+
efi_dir_path = self.target / efi_partition.mountpoint.relative_to('/') / 'EFI' / 'limine'
12571261
efi_dir_path.mkdir(parents=True, exist_ok=True)
12581262

12591263
for file in ('BOOTIA32.EFI', 'BOOTX64.EFI'):
@@ -1262,12 +1266,38 @@ def _add_limine_bootloader(
12621266
raise DiskError(f'Failed to install Limine in {self.target}{efi_partition.mountpoint}: {err}')
12631267

12641268
hook_command = (
1265-
f'/usr/bin/cp /usr/share/limine/BOOTIA32.EFI {efi_partition.mountpoint}/EFI/BOOT/'
1266-
f' && /usr/bin/cp /usr/share/limine/BOOTX64.EFI {efi_partition.mountpoint}/EFI/BOOT/'
1269+
f'/usr/bin/cp /usr/share/limine/BOOTIA32.EFI {efi_partition.mountpoint}/EFI/limine/'
1270+
f' && /usr/bin/cp /usr/share/limine/BOOTX64.EFI {efi_partition.mountpoint}/EFI/limine/'
12671271
)
1268-
else:
1269-
parent_dev_path = device_handler.get_parent_device_path(boot_partition.safe_dev_path)
12701272

1273+
# Create EFI boot menu entry for Limine.
1274+
try:
1275+
with open('/sys/firmware/efi/fw_platform_size') as fw_platform_size:
1276+
efi_bitness = fw_platform_size.read().strip()
1277+
except Exception as err:
1278+
error(f'Could not open or read /sys/firmware/efi/fw_platform_size to determine EFI bitness: {err}')
1279+
1280+
loader_path = None
1281+
if efi_bitness == '64':
1282+
loader_path = '/EFI/limine/BOOTX64.EFI'
1283+
elif efi_bitness == '32':
1284+
loader_path = '/EFI/limine/BOOTIA32.EFI'
1285+
else:
1286+
error('EFI bitness is neither 32 nor 64 bits')
1287+
1288+
try:
1289+
SysCommand(
1290+
'efibootmgr'
1291+
' --create'
1292+
f' --disk {parent_dev_path}'
1293+
f' --part {efi_partition.partn}'
1294+
' --label "Arch Linux Limine Bootloader"'
1295+
f' --loader {loader_path}'
1296+
' --verbose'
1297+
)
1298+
except Exception as err:
1299+
error(f'SysCommand for efibootmgr failed: {err}')
1300+
else:
12711301
if unique_path := device_handler.get_unique_path_for_device(parent_dev_path):
12721302
parent_dev_path = unique_path
12731303

0 commit comments

Comments
 (0)