@@ -1256,8 +1256,21 @@ def _add_limine_bootloader(
12561256
12571257 info (f"Limine EFI partition: { efi_partition .dev_path } " )
12581258
1259+ parent_dev_path = device_handler .get_parent_device_path (efi_partition .safe_dev_path )
1260+ is_target_usb = SysCommand (
1261+ f'udevadm info --no-pager --query=property --property=ID_BUS --value --name={ parent_dev_path } '
1262+ ).decode () == 'usb'
1263+
12591264 try :
1260- efi_dir_path = self .target / efi_partition .mountpoint .relative_to ('/' ) / 'EFI' / 'limine'
1265+ efi_dir_path = self .target / efi_partition .mountpoint .relative_to ('/' ) / 'EFI'
1266+ efi_dir_path_target = efi_partition .mountpoint / 'EFI'
1267+ if is_target_usb :
1268+ efi_dir_path = efi_dir_path / 'BOOT'
1269+ efi_dir_path_target = efi_dir_path_target / 'BOOT'
1270+ else :
1271+ efi_dir_path = efi_dir_path / 'limine'
1272+ efi_dir_path_target = efi_dir_path_target / 'limine'
1273+
12611274 efi_dir_path .mkdir (parents = True , exist_ok = True )
12621275
12631276 for file in ('BOOTIA32.EFI' , 'BOOTX64.EFI' ):
@@ -1268,40 +1281,41 @@ def _add_limine_bootloader(
12681281 config_path = efi_dir_path / 'limine.conf'
12691282
12701283 hook_command = (
1271- f'/usr/bin/cp /usr/share/limine/BOOTIA32.EFI { efi_partition . mountpoint } /EFI/limine /'
1272- f' && /usr/bin/cp /usr/share/limine/BOOTX64.EFI { efi_partition . mountpoint } /EFI/limine /'
1284+ f'/usr/bin/cp /usr/share/limine/BOOTIA32.EFI { efi_dir_path_target } /'
1285+ f' && /usr/bin/cp /usr/share/limine/BOOTX64.EFI { efi_dir_path_target } /'
12731286 )
12741287
1275- # Create EFI boot menu entry for Limine.
1276- parent_dev_path = device_handler .get_parent_device_path (efi_partition .safe_dev_path )
1277-
1278- try :
1279- with open ('/sys/firmware/efi/fw_platform_size' ) as fw_platform_size :
1280- efi_bitness = fw_platform_size .read ().strip ()
1281- except Exception as err :
1282- error (f'Could not open or read /sys/firmware/efi/fw_platform_size to determine EFI bitness: { err } ' )
1288+ if not is_target_usb :
1289+ # Create EFI boot menu entry for Limine.
1290+ parent_dev_path = device_handler .get_parent_device_path (efi_partition .safe_dev_path )
12831291
1284- loader_path = None
1285- if efi_bitness == '64' :
1286- loader_path = '/EFI/limine/BOOTX64.EFI'
1287- elif efi_bitness == '32' :
1288- loader_path = '/EFI/limine/BOOTIA32.EFI'
1289- else :
1290- error ('EFI bitness is neither 32 nor 64 bits' )
1292+ try :
1293+ with open ('/sys/firmware/efi/fw_platform_size' ) as fw_platform_size :
1294+ efi_bitness = fw_platform_size .read ().strip ()
1295+ except Exception as err :
1296+ error (f'Could not open or read /sys/firmware/efi/fw_platform_size to determine EFI bitness: { err } ' )
1297+
1298+ loader_path = None
1299+ if efi_bitness == '64' :
1300+ loader_path = '/EFI/limine/BOOTX64.EFI'
1301+ elif efi_bitness == '32' :
1302+ loader_path = '/EFI/limine/BOOTIA32.EFI'
1303+ else :
1304+ error ('EFI bitness is neither 32 nor 64 bits' )
12911305
1292- try :
1293- SysCommand (
1294- 'efibootmgr'
1295- ' --create'
1296- f' --disk { parent_dev_path } '
1297- f' --part { efi_partition .partn } '
1298- ' --label "Arch Linux Limine Bootloader"'
1299- f' --loader { loader_path } '
1300- ' --unicode'
1301- ' --verbose'
1302- )
1303- except Exception as err :
1304- error (f'SysCommand for efibootmgr failed: { err } ' )
1306+ try :
1307+ SysCommand (
1308+ 'efibootmgr'
1309+ ' --create'
1310+ f' --disk { parent_dev_path } '
1311+ f' --part { efi_partition .partn } '
1312+ ' --label "Arch Linux Limine Bootloader"'
1313+ f' --loader { loader_path } '
1314+ ' --unicode'
1315+ ' --verbose'
1316+ )
1317+ except Exception as err :
1318+ error (f'SysCommand for efibootmgr failed: { err } ' )
13051319 else :
13061320 boot_limine_path = self .target / 'boot' / 'limine'
13071321 boot_limine_path .mkdir (parents = True , exist_ok = True )
0 commit comments