4

I have here a machine which won't boot 64-bit kernels (it has efi32 with a little bit of... uncommon firmware).

Currently, my only way to boot my 64-bit linux system is:

  1. Booting a 32-bit distro from a boot/live cd,
  2. Using kexec to boot my own 64 bit kernel.

Of course I could reinstall a 32-bit distro, but this is not what I want. I want a 32bit kernel/initrd combo, which could work as a bootloader to my real, 64bit kernel/initrd.

It were a minimal initrd system which is capable to load and start my own secondary kernel. Is there any already existing solution for the job?

2 Answers 2

3

A 32-bit grub bootloader will boot a 64-bit Linux image compiled with the CONFIG_EFI_MIXED option using the "linux" and "initrd" commands.

Note that these Grub commands execute EFI's ExitBootServices() prior to starting the kernel. Thus the kernel cannot use secure boot nor can it access the ROMs of PCI slots (most notably the BIOS of the graphics' card).

An alternative is to run the "shim" bootloader and then Grub and use Grub's linuxefi and linuxrdefi commands. These don't run ExitBootServices() but call into a EFI stub in the kernel which copies out ROMs, etc and then calls ExitBootServices() itself before starting the kernel proper. Attempting to run Grub's "linuxefi" command without the shim bootloader results in a "incorrect checksum" error, regardless of the presence or otherwise of secure boot. Unfortunately this approach has two issues: (1) the kernel must be 32-bit and (2) there is currently a bug in the 32-bit EFI stub which prevents the kernel from starting (it hangs with no output).

The bug is notorious. Moreover some 64-bit linux images fail, strongly suggesting some alignment or data-overwriting issue.

The only way forward to get the result you want is to modify the kernel so that it can be started with a 32-bit EFI stub and then transition to the 64-bit kernel proper. It is possible that the author of CONFIG_EFI_MIXED is working on this, perhaps you could email them.

1

CONFIG_EFI_MIXED might be what you need.

12
  • Thank you, it seems very-very promising! But this is what I don't understand: "Note that it is not possible to boot a mixed-mode enabled kernel via the EFI boot stub - a bootloader that supports the EFI handover protocol must be used." What the heck is that?
    – peterh
    Sep 28, 2014 at 15:37
  • I didn't use this myself so far (albeit could run into this shortly); the original announce (lkml.org/lkml/2014/3/4/242) does mention "Syslinux, efilinux, Grub" though. Sep 29, 2014 at 20:03
  • I am currently on the recompilation of a suse kernel, if it works I will accept your answer! Thank for your help!
    – peterh
    Sep 29, 2014 at 20:57
  • Did it work? I haven't tested this yet although it looked like an answer to one of my own problems when this code has been added to the kernel (the problem was low-prio and is still unsolved, so I'm still interested). Oct 12, 2014 at 15:37
  • 1
    My problem was, that my computer has a 64bit cpu, but only a 32bit EFI. And the 32bit EFI simply won't boot a 64bit kernel. The 64bit kernel had been able to get a 32bit EFI stub, but it simply didn't exist in linux, not even with the new kernel compilation flags. But it supported 64bit windowses even if they don't support EFI, thus it had to have some like a "BIOS emulation mode". The firmware bootloader won't see that, but refind could. It was the story. :-)
    – peterh
    Nov 2, 2014 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.