projg2 / installkernel-gentoo

Gentoo fork of installkernel from debianutils
GNU General Public License v2.0
19 stars 7 forks source link

On the .efi extension #11

Closed kuraga closed 10 months ago

kuraga commented 10 months ago

Good day!

We have the line:

https://github.com/projg2/installkernel-gentoo/blob/e9b9c694a20df9cac1469d4145434716d4235551/hooks/90-uki-copy.install#L25

But when do we have the .efi extension? I don't see that case in the main binary...

P.S. I'm trying to manage the Linux kernel EFI stub (not UKI) using installkernel. And the sys-kernel/gentoo-kernel-bin's image is an EFI stub but it's not == *.efi.

Nowa-Ammerlaan commented 10 months ago

We have the .efi extension if we are installing an UKI (i.e. if uki.efi is present at the location of the kernel image): https://github.com/projg2/installkernel-gentoo/blob/e9b9c694a20df9cac1469d4145434716d4235551/installkernel#L100

90-uki-copy is for installing UKIs in the layout that is common for UKIs (Boot Loader Specification type 2), systemd-boot auto-discovers UKIs in that location. It would be super confusing if this plugin would also install plain kernel images to the same location with the same name.

If you want to EFI stub without an UKI then all that is required is to have the kernel image somewhere on the ESP, if the ESP is mounted at /boot this is already the case and no extra steps are required. If the ESP is not at /boot I recommend writing some custom postinst script to copy it there. You likely need a custom postinst script anyway to update the firmware configuration with efibootmgr (or copy the kernel image to the same location always, which I would not recommend because it makes it impossible to have fallback kernel versions).

kuraga commented 10 months ago

@AndrewAmmerlaan ,

We have the .efi extension if we are installing an UKI (i.e. if uki.efi is present at the location of the kernel image):

https://github.com/projg2/installkernel-gentoo/blob/e9b9c694a20df9cac1469d4145434716d4235551/installkernel#L100

Aha, "if uki.efi is [already] present". Which tool generate such file? Thanks.

90-uki-copy is for installing UKIs in the layout that is common for UKIs (Boot Loader Specification type 2), systemd-boot auto-discovers UKIs in that location. It would be super confusing if this plugin would also install plain kernel images to the same location with the same name.

If you want to EFI stub without an UKI then all that is required is to have the kernel image somewhere on the ESP, if the ESP is mounted at /boot this is already the case and no extra steps are required. If the ESP is not at /boot I recommend writing some custom postinst script to copy it there. You likely need a custom postinst script anyway to update the firmware configuration with efibootmgr (or copy the kernel image to the same location always, which I would not recommend because it makes it impossible to have fallback kernel versions).

Are there plans for the efi USE/option?

Nowa-Ammerlaan commented 10 months ago

Aha, "if uki.efi is [already] present". Which tool generate such file? Thanks.

Systemd's ukify or dracut if uefi=yes is in /etc/dracut.conf, plugins for these tools are installed by the ukify and dracut USE flags on installkernel.

If you want an UKI without any initramfs then ukify is your only option, dracut will always make an initramfs first and then generate an UKI, though you can of course configure dracut to create a very small and bare bones initramfs.

See also: https://wiki.gentoo.org/wiki/Unified_kernel_image https://wiki.gentoo.org/wiki/Installkernel

Are there plans for the efi USE/option?

What would this do? If we want to move the whole installation tree then I think it makes more sense to remove the hardcoded /boot and allow users to override this (with e.g. /efi). Note that systemd's kernel-install (enabled with USE=systemd) can already do this.

kuraga commented 10 months ago

Thanks!

Nowa-Ammerlaan commented 8 months ago

P.S. I'm trying to manage the Linux kernel EFI stub (not UKI) using installkernel. And the sys-kernel/gentoo-kernel-bin's image is an EFI stub but it's not == *.efi.

See also: https://github.com/projg2/installkernel-gentoo/issues/19

Nowa-Ammerlaan commented 8 months ago

If you want to EFI stub without an UKI then all that is required is to have the kernel image somewhere on the ESP, if the ESP is mounted at /boot this is already the case and no extra steps are required. If the ESP is not at /boot I recommend writing some custom postinst script to copy it there. You likely need a custom postinst script anyway to update the firmware configuration with efibootmgr (or copy the kernel image to the same location always, which I would not recommend because it makes it impossible to have fallback kernel versions).

This is now a bit easier in version 29 via the new USE flag efistub.

kuraga commented 7 months ago

Changed in 34 via #20. Thanks!