0

I have a dev machine with BIOS and after compiling my kernel and initrd, I'm able to use it with a simple menuentry:

menuentry "mlinux" {
       linux /boot/mlinuz quiet
       initrd /boot/minitramfs
}

However running this on another machine with UEFI fails, I get:

error: kernel doesn't support EFI handover.
error: you need to load the kernel first.

I thought maybe this has to do with lack of support for UEFI in my kernel so I recompiled it with EFI_STUB support (had to enable ACPI too). Now I get a dark screen. If I add echo before each step and remove quiet, I'll see echo messages but nothing more, no kernel msg, nothing.

After seeing this question and this post, I copied my kernel to:

  • /boot/efi/mlinuz.efi
  • /boot/efi/EFI/mlinuz.efi
  • /boot/efi/EFI/BOOT/mlinuz.efi

and have used theses addresses as my path in menuentry, still none of them work saying file can't be found. Where should I copy the file and what should be in my menuentry?

Side question: if I boot with my own linux kernel but the custom initrd, I can launch my program but can't interact with it using keyboard. Any idea why!?

EDIT: found about linuxefi and initrdefi but since it can't find the file, I drop to command line, use ls to find my hard and then use linuxefi (hd0,pt2)/mlinuz64.efi but it doesn't do anything.

7
  • This all hugely depends on your particular hardware, UEFI firmware and your actual kernel configuration. Side answer: it seems you don't either have a console driver or your application doesn't use console properly. This again depends on what console there is and how you are using it. Commented Jun 30, 2022 at 9:27
  • @NikitaKipriyanov what should I be looking into? how can I start debugging it, what to check, etc? re side answer: it works just fine on bios machine, on qemu, etc Commented Jun 30, 2022 at 10:22
  • There are quite a number of tunables. Start by properly describing: which hardware you have and which firmware is there. Say which related kernel CONFIG_* variables you configured and how. If that's GRUB, it should generally not bother whether your Linux supports EFI, because it runs it with via multiboot spec, not UEFI. The EFI stub is only needed for booting Linux without a separate bootloader; in this case, it is wise to include initramfs and command line into kernel image file. Commented Jun 30, 2022 at 11:19
  • @NikitaKipriyanov I'm using GRUB2 (Ubuntu) and it was asking for EFI handover, previously I had CONFIG of EFI & EFI_STUB enabled (which made error go away but showed blank screen) then saw this and after enabling FRAMEBUFFER related confs, I can now see the output. I guess framebuffer was the issue and I only needed CONFIG_EFI and not even CONFIG_EFI_STUB? Commented Jul 1, 2022 at 4:32
  • EFI Framebuffer depends on EFI. If you plan to use Grub (or other bootloader) you may omit EFI Stub, which is only needed to load the kernel directly by the firmware without an additional bootloader. Commented Jul 1, 2022 at 5:49

1 Answer 1

2

For anyone running into a blank screen as well, the problem was that I needed to enable FRAMEBUFFER:

CONFIG_FB_EFI=y
CONFIG_FRAMEBUFFER_CONSOLE=y

Turns out you can also disable CONFIG_EFI_STUB if you're using grub and not direct boot.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.