Subject: Re: bug#30311: efi-less grub install fails

From: Danny Milosavljevic <[email-masked]>
Date: Tue, 20 Feb 2018 23:00:27 +0100

Hi Ricardo,

On Tue, 20 Feb 2018 22:49:19 +0100
Ricardo Wurmus <[email-masked]> wrote:

> So the value “/sys/firmware/non-efi” might as well be
> “/does-not-exist”?

Yes.

> Your patch subject says “Make sure that non-EFI grub doesn't try to use
> EFI”, but the problem I had was that GRUB insisted on being passed a
> “--target” option.  

> That was with a GRUB installation on a system in
> legacy mode.  Do you mean that this failed because GRUB erroneously
> attempted an EFI installation?

Yes, I think so.

There's a default-platform function in grub which determines the default
platform to use at runtime if you don't specify one.  It one checks for
the existence of /sys/firmware/efi, and if so, returns "i386-efi" or
"x86_64-efi" (see ./grub-core/osdep/linux/platform.c).

Grub's "configure" script has the ability to select which platform you
want to compile.  For the "grub" package, we choose i386, and for the
"grub-efi" package, we choose i386-efi.

The "grub-hybrid" package unions the "grub" and "grub-efi" packages,
preferring files from the "grub-efi" package.  I think this
configuration is what upstream actually tests (only).

In the "grub" package we then had the situation that it was compiled
for i386 (not EFI) but THEIR OWN default-platform function specified
to use i386-efi which is some seriously strange stuff.

Do you think that this was not the cause?