void-packages icon indicating copy to clipboard operation
void-packages copied to clipboard

efibootmgr kernel hook does not create entry

Open dkwo opened this issue 1 year ago • 6 comments

Is this a new report?

Yes

System Info

Void 5.18.16_1 x86_64-musl GenuineIntel uptodate rrnDFFFFFFFFF

Package(s) Affected

efibootmgr-18_1

Does a report exist for this bug with the project's home (upstream) and/or another distro?

Cannot find any.

Expected behaviour

The kernel hook does the job of creating a new entry.

Actual behaviour

No entry is created: more precisely, it creates an entry, but does not add it to the bootorder. This is from inside the installer chroot (both the working way and the broken one).

The package itself works if I use doas efibootmgr --disk /dev/nvme0n1 --part 1 --create --label "Void Linux with test kernel" --loader /vmlinuz-5.18.16_1 --unicode 'loglevel=4 rd.luks.name=809df427-d7d5-408c-a195-3be6e8681333=cryptroot root=/dev/mapper/cryptroot rd.luks.options=discard initrd=\initramfs-5.18.16_1.img' --verbose

I'm using

$ cat /etc/default/efibootmgr-kernel-hook 
# Options for the kernel hook script installed by the efibootmgr package.
MODIFY_EFI_ENTRIES=1
# Kernel command-line options.
OPTIONS="loglevel=4 rd.luks.name=809df427-d7d5-408c-a195-3be6e8681333=cryptroot root=/dev/mapper/cryptroot rd.luks.options=discard"
# Disk where EFI Partition is.  Default is /dev/sda
DISK="/dev/nvme0n1"
# Partition number of EFI Partition.  Default is 1
PART=1

Steps to reproduce

xbps-reconfigure -f linux5.18

dkwo avatar Aug 08 '22 13:08 dkwo

For some reason, the entry is created, but not placed in bootorder:

$ doas efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0017,0018,0019,001A,001B,001C
Boot0001* Void Linux with test kernel	HD(1,GPT,4a04d763-6e6c-4f50-a11b-c5d1092ccee5,0x800,0x100000)/File(\vmlinuz-5.18.16_1)6c006f0067006c006500760065006c003d0034002000720064002e006c0075006b0073002e006e0061006d0065003d00380030003900640066003400320037002d0064003700640035002d0034003000380063002d0061003100390035002d003300620065003600650038003600380031003300330033003d006300720079007000740072006f006f007400200072006f006f0074003d002f006400650076002f006d00610070007000650072002f006300720079007000740072006f006f0074002000720064002e006c0075006b0073002e006f007000740069006f006e0073003d006400690073006300610072006400200069006e0069007400720064003d005c0069006e0069007400720061006d00660073002d0035002e00310038002e00310036005f0031002e0069006d006700
Boot0010  Setup	FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011  Boot Menu	FvFile(126a762d-5758-4fca-8531-201a7f57f850)
Boot0012  Diagnostic Splash Screen	FvFile(a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380)
Boot0013  Lenovo Diagnostics	FvFile(3f7e615b-0d45-4f80-88dc-26b234958560)
Boot0014  Startup Interrupt Menu	FvFile(f46ee6f4-4785-43a3-923d-7f786c3c8479)
Boot0015  Rescue and Recovery	FvFile(665d3f60-ad3e-4cad-8e26-db46eee9f1b5)
Boot0016  MEBx Hot Key	FvFile(ac6fd56a-3d41-4efd-a1b9-870293811a28)
Boot0017* USB CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0018* USB FDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0019* NVMe0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,001c199932d94c4eae9aa0b6e98eb8a400)
Boot001A* ATA HDD0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f600)
Boot001B* USB HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,33e821aaaf33bc4789bd419f88c50803)
Boot001C* PCI LAN	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
Boot001D* IDER BOOT CDROM	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,1,0)
Boot001E* IDER BOOT Floppy	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,0,0)
Boot001F* ATA HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f6)
Boot0020* ATAPI CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)
$ doas xbps-reconfigure -f linux5.18
linux5.18: configuring ...
Executing post-install kernel hook: 20-booster ...
Executing post-install kernel hook: 50-efibootmgr ...
linux5.18: configured successfully.
$ doas efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0017,0018,0019,001A,001B,001C
Boot0000* Void Linux with kernel 5.18	HD(1,GPT,4a04d763-6e6c-4f50-a11b-c5d1092ccee5,0x800,0x100000)/File(\vmlinuz-5.18.16_1)6c006f0067006c006500760065006c003d0034002000720064002e006c0075006b0073002e006e0061006d0065003d00380030003900640066003400320037002d0064003700640035002d0034003000380063002d0061003100390035002d003300620065003600650038003600380031003300330033003d006300720079007000740072006f006f007400200072006f006f0074003d002f006400650076002f006d00610070007000650072002f006300720079007000740072006f006f0074002000720064002e006c0075006b0073002e006f007000740069006f006e0073003d006400690073006300610072006400200069006e0069007400720064003d002f0069006e0069007400720061006d00660073002d0035002e00310038002e00310036005f0031002e0069006d006700
Boot0001* Void Linux with test kernel	HD(1,GPT,4a04d763-6e6c-4f50-a11b-c5d1092ccee5,0x800,0x100000)/File(\vmlinuz-5.18.16_1)6c006f0067006c006500760065006c003d0034002000720064002e006c0075006b0073002e006e0061006d0065003d00380030003900640066003400320037002d0064003700640035002d0034003000380063002d0061003100390035002d003300620065003600650038003600380031003300330033003d006300720079007000740072006f006f007400200072006f006f0074003d002f006400650076002f006d00610070007000650072002f006300720079007000740072006f006f0074002000720064002e006c0075006b0073002e006f007000740069006f006e0073003d006400690073006300610072006400200069006e0069007400720064003d005c0069006e0069007400720061006d00660073002d0035002e00310038002e00310036005f0031002e0069006d006700
Boot0010  Setup	FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011  Boot Menu	FvFile(126a762d-5758-4fca-8531-201a7f57f850)
Boot0012  Diagnostic Splash Screen	FvFile(a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380)
Boot0013  Lenovo Diagnostics	FvFile(3f7e615b-0d45-4f80-88dc-26b234958560)
Boot0014  Startup Interrupt Menu	FvFile(f46ee6f4-4785-43a3-923d-7f786c3c8479)
Boot0015  Rescue and Recovery	FvFile(665d3f60-ad3e-4cad-8e26-db46eee9f1b5)
Boot0016  MEBx Hot Key	FvFile(ac6fd56a-3d41-4efd-a1b9-870293811a28)
Boot0017* USB CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0018* USB FDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0019* NVMe0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,001c199932d94c4eae9aa0b6e98eb8a400)
Boot001A* ATA HDD0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f600)
Boot001B* USB HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,33e821aaaf33bc4789bd419f88c50803)
Boot001C* PCI LAN	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
Boot001D* IDER BOOT CDROM	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,1,0)
Boot001E* IDER BOOT Floppy	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,0,0)
Boot001F* ATA HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f6)
Boot0020* ATAPI CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)

dkwo avatar Aug 08 '22 14:08 dkwo

If I do it by hand, then it works:

$ doas efibootmgr -qc -d /dev/nvme0n1 -p 1 -L "Void Linux with kernel xxx" -l /vmlinuz-5.18.16_1 -u "loglevel=4 rd.luks.name=809df427-d7d5-408c-a195-3be6e8681333=cryptroot root=/dev/mapper/cryptroot rd.luks.options=discard initrd=/initramfs-5.18.16_1.img"
$ doas efibootmgr 
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0000,0001,0017,0018,0019,001A,001B,001C
Boot0000* Void Linux with kernel xxx	HD(1,GPT,4a04d763-6e6c-4f50-a11b-c5d1092ccee5,0x800,0x100000)/File(\vmlinuz-5.18.16_1)6c006f0067006c006500760065006c003d0034002000720064002e006c0075006b0073002e006e0061006d0065003d00380030003900640066003400320037002d0064003700640035002d0034003000380063002d0061003100390035002d003300620065003600650038003600380031003300330033003d006300720079007000740072006f006f007400200072006f006f0074003d002f006400650076002f006d00610070007000650072002f006300720079007000740072006f006f0074002000720064002e006c0075006b0073002e006f007000740069006f006e0073003d006400690073006300610072006400200069006e0069007400720064003d002f0069006e0069007400720061006d00660073002d0035002e00310038002e00310036005f0031002e0069006d006700
Boot0001* Void Linux with test kernel	HD(1,GPT,4a04d763-6e6c-4f50-a11b-c5d1092ccee5,0x800,0x100000)/File(\vmlinuz-5.18.16_1)6c006f0067006c006500760065006c003d0034002000720064002e006c0075006b0073002e006e0061006d0065003d00380030003900640066003400320037002d0064003700640035002d0034003000380063002d0061003100390035002d003300620065003600650038003600380031003300330033003d006300720079007000740072006f006f007400200072006f006f0074003d002f006400650076002f006d00610070007000650072002f006300720079007000740072006f006f0074002000720064002e006c0075006b0073002e006f007000740069006f006e0073003d006400690073006300610072006400200069006e0069007400720064003d005c0069006e0069007400720061006d00660073002d0035002e00310038002e00310036005f0031002e0069006d006700
Boot0010  Setup	FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011  Boot Menu	FvFile(126a762d-5758-4fca-8531-201a7f57f850)
Boot0012  Diagnostic Splash Screen	FvFile(a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380)
Boot0013  Lenovo Diagnostics	FvFile(3f7e615b-0d45-4f80-88dc-26b234958560)
Boot0014  Startup Interrupt Menu	FvFile(f46ee6f4-4785-43a3-923d-7f786c3c8479)
Boot0015  Rescue and Recovery	FvFile(665d3f60-ad3e-4cad-8e26-db46eee9f1b5)
Boot0016  MEBx Hot Key	FvFile(ac6fd56a-3d41-4efd-a1b9-870293811a28)
Boot0017* USB CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0018* USB FDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0019* NVMe0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,001c199932d94c4eae9aa0b6e98eb8a400)
Boot001A* ATA HDD0	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f600)
Boot001B* USB HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,33e821aaaf33bc4789bd419f88c50803)
Boot001C* PCI LAN	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
Boot001D* IDER BOOT CDROM	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,1,0)
Boot001E* IDER BOOT Floppy	PciRoot(0x0)/Pci(0x16,0x2)/Ata(0,0,0)
Boot001F* ATA HDD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f6)
Boot0020* ATAPI CD	VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)

Perhaps efibootmgr.post-install is responsible for my issue?

dkwo avatar Aug 08 '22 15:08 dkwo

Can reproduce. The hook is brittle.

prez avatar Aug 11 '22 21:08 prez

Since I see a Lenovo mark in there, I presume the system at hand is a laptop, or at the very least some specific OEM system. Knowing how finicky laptop/OEM firmware can be, it would be useful to know it that same exact configuration, exported to another system, would also throw the same error or otherwise work smoothly (I've seen it happening).

This, obviously, does not mean that the hook is not at fault. In general, with hooking mechanisms, the more precautions the better. But let's not forget how finicky laptop/OEM firmware also is on average (Been there, done that). Can anyone reproduce this with a different configuration, especially with hardware from a different manufacturer?

TeusLollo avatar Aug 12 '22 16:08 TeusLollo

it would be useful to know it that same exact configuration, exported to another system, would also throw the same error or otherwise work smoothly (I've seen it happening).

I can reproduce the issue with the same installation (hard drive) on both a desktop machine and a corebooted ThinkPad, I think we can rule out the hardware.

prez avatar Aug 13 '22 03:08 prez

The hardware is a Lenovo Thinkpad T460s, whose firmware is a piece of crap, I agree. Thanks for confirming with different hardware. For the moment, it suffices to issue something like doas efibootmgr -o 3,2,0,1 after every update, to fix the order by hand, as the entries are correctly created.

dkwo avatar Aug 13 '22 08:08 dkwo

The last step in post-install looks suspicious

efibootmgr -qo $bootorder

sgn avatar Aug 22 '22 12:08 sgn

The last step in post-install looks suspicious

efibootmgr -qo $bootorder

The step itself looks nominally correct to me, checking the man-page.

Problem is, we got a fairly complex setup at hand, as evidenced by the "manual" command OP reported working:

doas efibootmgr --disk /dev/nvme0n1 --part 1 --create --label "Void Linux with test kernel" --loader /vmlinuz-5.18.16_1 --unicode 'loglevel=4 rd.luks.name=809df427-d7d5-408c-a195-3be6e8681333=cryptroot root=/dev/mapper/cryptroot rd.luks.options=discard initrd=\initramfs-5.18.16_1.img' --verbose

This is utilizing LUKS-based filesystem encryption, which can sometimes fail to boot due to seemingly-unrelated issues. It would also be necessary to understand what values are being assigned into the $bootorder variable.

  1. Are we by chance trying to boot through an EFISTUB? Because I don't see any bootloader-specific .efi file in the "manual" command the OP has reported to be working. Seemingly, OP is not using GRUB, ad example. For comparison, a GRUB-based non-LUKS setup would use the following command: efibootmgr -c -d /dev/sdx -p 1 -L "<label>" -l "/EFI/<label>/grubx64.efi".

  2. Has the directory /dev/nvme0n1 (Which I presume being the EFI directory) been marked with the proper esp flag?

  3. This may not be particularly useful, but what's the output of lsblk, accounting also for the LUKS configuration? And what file systems are being utilized into relevant partitions? Btrfs with LUKS is known to throw seemingly-random errors for unclear reasons.

It's working when issuing a manual command, OP said. Why does it not when automated? What's missing, if anything? Is everything that should go into $bootorder variable being assigned?

TeusLollo avatar Aug 22 '22 15:08 TeusLollo

https://github.com/void-linux/void-packages/blob/a279abf769ef7cab6ebb49d8c99bf774a2ff97b8/srcpkgs/efibootmgr/files/README.voidlinux#L17-L19

Duncaen avatar Aug 22 '22 15:08 Duncaen

@Duncaen You're right, I missed it, sorry about that. Then it's working as expected.

(For me, it's booting an efistub, without grub, using its default loader; the partition is of course flagged appropriately.)

dkwo avatar Aug 22 '22 15:08 dkwo