unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30311: efi-less grub install fails
@ 2018-01-31 18:55 Ricardo Wurmus
  2018-01-31 23:34 ` Danny Milosavljevic
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ricardo Wurmus @ 2018-01-31 18:55 UTC (permalink / raw)
  To: 30311

“guix system init” fails with a configuration file that specifies
grub-bootloader (not grub-efi-bootloader).

“grub-install” reports an error about “lib/grub/x86_64-efi/modinfo.sh”
not being available.  It suggests passing “--target” or “--device”.

Our invocation of grub-install does not include a “--target” argument.
Only after I edited it to pass “--target=i386-pc” did “guix system init”
pass.

This is on an x86_64 laptop where “legacy” BIOS booting is enabled.

--
Ricardo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-01-31 18:55 bug#30311: efi-less grub install fails Ricardo Wurmus
@ 2018-01-31 23:34 ` Danny Milosavljevic
  2018-02-01 12:40   ` Marius Bakke
  2018-01-31 23:55 ` Ludovic Courtès
  2018-02-18 16:20 ` Mark H Weaver
  2 siblings, 1 reply; 19+ messages in thread
From: Danny Milosavljevic @ 2018-01-31 23:34 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 30311

Hi Ricardo,

On Wed, 31 Jan 2018 19:55:58 +0100
Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> wrote:

> “guix system init” fails with a configuration file that specifies
> grub-bootloader (not grub-efi-bootloader).
> 
> “grub-install” reports an error about “lib/grub/x86_64-efi/modinfo.sh”
> not being available.  It suggests passing “--target” or “--device”.
> 
> Our invocation of grub-install does not include a “--target” argument.
> Only after I edited it to pass “--target=i386-pc” did “guix system init”
> pass.

Hmm, I wonder what happened here.

We've been very careful to keep grub and grub-efi separate.

The entire directory lib/grub/x86_64-efi shouldn't be available in the
"grub" package output - and I checked on master, it isn't.  Good.

So that leaves automatic target selection as the culprit.

And indeed, there's a call to grub_install_get_default_x86_platform
in util/grub-install.c .  And that checks for availability of
/sys/firmware/efi and if it exists, defaults to EFI.

I think it's a bug in grub to do that for a grub which doesn't have EFI
platform support. :P

We could just always pass i386-pc in install-grub for i386, but then
we lose i386-ieee1275 (which I have never heard anyone using so maybe
not so bad).

Please report a bug with grub...

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-01-31 18:55 bug#30311: efi-less grub install fails Ricardo Wurmus
  2018-01-31 23:34 ` Danny Milosavljevic
@ 2018-01-31 23:55 ` Ludovic Courtès
  2018-02-18 16:20 ` Mark H Weaver
  2 siblings, 0 replies; 19+ messages in thread
From: Ludovic Courtès @ 2018-01-31 23:55 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 30311

Heya,

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> “guix system init” fails with a configuration file that specifies
> grub-bootloader (not grub-efi-bootloader).
>
> “grub-install” reports an error about “lib/grub/x86_64-efi/modinfo.sh”
> not being available.  It suggests passing “--target” or “--device”.
>
> Our invocation of grub-install does not include a “--target” argument.
> Only after I edited it to pass “--target=i386-pc” did “guix system init”
> pass.
>
> This is on an x86_64 laptop where “legacy” BIOS booting is enabled.

To complement from what we’ve discussed on IRC:

  • It’s a UEFI laptop with legacy-BIOS enabled, but UEFI still.

  • AIUI the installation image boots in UEFI mode on UEFI machines, and
    then ‘grub-install’ (probably via ‘efivar’ or /sys or similar)
    detects that it’s UEFI, decides that the target is thus
    “x86_64-efi”, and fails because it lacks the EFI files.

I can think of two possible workarounds:

  1. Default to ‘grub-hybrid’.  But in that case, you’d have done a UEFI
     install unconditionally.

  2. For ‘grub-bootloader’ (not EFI), always pass ‘--target=i386-pc’.

Danny, Marius, thoughts?  :-)

Ludo’.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-01-31 23:34 ` Danny Milosavljevic
@ 2018-02-01 12:40   ` Marius Bakke
  2018-02-18 11:28     ` Ricardo Wurmus
  0 siblings, 1 reply; 19+ messages in thread
From: Marius Bakke @ 2018-02-01 12:40 UTC (permalink / raw)
  To: Danny Milosavljevic, Ricardo Wurmus; +Cc: 30311

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Ricardo,
>
> On Wed, 31 Jan 2018 19:55:58 +0100
> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> wrote:
>
>> “guix system init” fails with a configuration file that specifies
>> grub-bootloader (not grub-efi-bootloader).
>> 
>> “grub-install” reports an error about “lib/grub/x86_64-efi/modinfo.sh”
>> not being available.  It suggests passing “--target” or “--device”.
>> 
>> Our invocation of grub-install does not include a “--target” argument.
>> Only after I edited it to pass “--target=i386-pc” did “guix system init”
>> pass.
>
> Hmm, I wonder what happened here.
>
> We've been very careful to keep grub and grub-efi separate.
>
> The entire directory lib/grub/x86_64-efi shouldn't be available in the
> "grub" package output - and I checked on master, it isn't.  Good.
>
> So that leaves automatic target selection as the culprit.
>
> And indeed, there's a call to grub_install_get_default_x86_platform
> in util/grub-install.c .  And that checks for availability of
> /sys/firmware/efi and if it exists, defaults to EFI.
>
> I think it's a bug in grub to do that for a grub which doesn't have EFI
> platform support. :P
>
> We could just always pass i386-pc in install-grub for i386, but then
> we lose i386-ieee1275 (which I have never heard anyone using so maybe
> not so bad).

I agree, passing --target seems like the best workaround for this GRUB
bug.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-01 12:40   ` Marius Bakke
@ 2018-02-18 11:28     ` Ricardo Wurmus
  0 siblings, 0 replies; 19+ messages in thread
From: Ricardo Wurmus @ 2018-02-18 11:28 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 30311-done


Marius Bakke <mbakke@fastmail.com> writes:

> Danny Milosavljevic <dannym@scratchpost.org> writes:
>
>> Hi Ricardo,
>>
>> On Wed, 31 Jan 2018 19:55:58 +0100
>> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> wrote:
>>
>>> “guix system init” fails with a configuration file that specifies
>>> grub-bootloader (not grub-efi-bootloader).
>>> 
>>> “grub-install” reports an error about “lib/grub/x86_64-efi/modinfo.sh”
>>> not being available.  It suggests passing “--target” or “--device”.
>>> 
>>> Our invocation of grub-install does not include a “--target” argument.
>>> Only after I edited it to pass “--target=i386-pc” did “guix system init”
>>> pass.
>>
>> Hmm, I wonder what happened here.
>>
>> We've been very careful to keep grub and grub-efi separate.
>>
>> The entire directory lib/grub/x86_64-efi shouldn't be available in the
>> "grub" package output - and I checked on master, it isn't.  Good.
>>
>> So that leaves automatic target selection as the culprit.
>>
>> And indeed, there's a call to grub_install_get_default_x86_platform
>> in util/grub-install.c .  And that checks for availability of
>> /sys/firmware/efi and if it exists, defaults to EFI.
>>
>> I think it's a bug in grub to do that for a grub which doesn't have EFI
>> platform support. :P
>>
>> We could just always pass i386-pc in install-grub for i386, but then
>> we lose i386-ieee1275 (which I have never heard anyone using so maybe
>> not so bad).
>
> I agree, passing --target seems like the best workaround for this GRUB
> bug.

Okay, I’ve added “--target=i386-pc” to the list of arguments.

Thanks for the comments.

-- 
Ricardo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-01-31 18:55 bug#30311: efi-less grub install fails Ricardo Wurmus
  2018-01-31 23:34 ` Danny Milosavljevic
  2018-01-31 23:55 ` Ludovic Courtès
@ 2018-02-18 16:20 ` Mark H Weaver
  2018-02-18 16:49   ` Danny Milosavljevic
  2018-02-20  3:21   ` Marius Bakke
  2 siblings, 2 replies; 19+ messages in thread
From: Mark H Weaver @ 2018-02-18 16:20 UTC (permalink / raw)
  To: 30311; +Cc: Ricardo Wurmus

reopen 30311
thanks

Hi Ricardo,

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> writes:
> Okay, I’ve added “--target=i386-pc” to the list of arguments.

This change breaks my mips64el-linux GuixSD system, which is supported
by GRUB, but where "--target=i386-pc" is obviously not appropriate.  On
my system I need a different 'target' setting.

It would be great if we could find another solution to this issue.
GRUB's automatic target selection seems to work on most systems, since
we've been relying on it for a long time without anyone reporting
problems until this bug report.

In the rare cases where GRUB fails to detect the target, perhaps we
could provide a way to specify an explicit GRUB 'target' in the grub
configuration?  What do you think?

      Mark

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-18 16:20 ` Mark H Weaver
@ 2018-02-18 16:49   ` Danny Milosavljevic
  2018-02-20 21:40     ` Ricardo Wurmus
  2018-02-20  3:21   ` Marius Bakke
  1 sibling, 1 reply; 19+ messages in thread
From: Danny Milosavljevic @ 2018-02-18 16:49 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: Ricardo Wurmus, 30311

[-- Attachment #1: Type: text/plain, Size: 897 bytes --]

Hi Mark,

> This change breaks my mips64el-linux GuixSD system, which is supported
> by GRUB, but where "--target=i386-pc" is obviously not appropriate.  On
> my system I need a different 'target' setting.

A pretty safe workaround is to substitute /sys/firmware/efi by /sys/firmware/non-efi
in ./grub-core/osdep/linux/platform.c for non-efi grub.

See attachment...

> In the rare cases where GRUB fails to detect the target, perhaps we
> could provide a way to specify an explicit GRUB 'target' in the grub
> configuration?

I still think that upstream should fix this bug.  It's silly that we have to
massage grub to not select a target which grub wasn't compiled for - we
patch/configure one part of grub so another part of grub isn't confused.

It's the same package :P

Bootloader configuration is complicated enough already.  In this case I'd rather
grub did the right thing automatically.

[-- Attachment #2: 0001-gnu-grub-Make-sure-that-non-EFI-grub-doesn-t-try-to-.patch --]
[-- Type: text/x-patch, Size: 1813 bytes --]

From 263b1dc0de9643094bc41f4be47b4b2317e95d7c Mon Sep 17 00:00:00 2001
From: Danny Milosavljevic <dannym@scratchpost.org>
Date: Sun, 18 Feb 2018 17:30:48 +0100
Subject: [FIXME] gnu: grub: Make sure that non-EFI grub doesn't try to use
 EFI.
Tags: patch

* gnu/packages/bootloader.scm (grub)[arguments]<:phases>
[patch-/sys/firmware/efi-out]: New phase.
(grub-efi)[arguments]<:phases>[patch-/sys/firmware/efi-out]: Delete phase.

Fixes <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30311>.
---
 gnu/packages/bootloaders.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 59eb22f24..c09829e17 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -103,6 +103,11 @@
                      (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
                      (system* "gunzip" "unifont.bdf.gz")
                      #t))
+                  (add-after 'unpack 'patch-/sys/firmware/efi-out
+                   (lambda _
+                     (substitute* "grub-core/osdep/linux/platform.c"
+                      (("/sys/firmware/efi") "/sys/firmware/non-efi"))
+                     #t))
                   (add-before 'check 'disable-flaky-test
                     (lambda _
                       ;; This test is unreliable. For more information, see:
@@ -177,6 +182,7 @@ menu to select one of the installed operating systems.")
             `(cons "--with-platform=efi" ,flags))
            ((#:phases phases)
             `(modify-phases ,phases
+               (delete 'patch-/sys/firmware/efi-out)
                (add-after 'patch-stuff 'use-absolute-efibootmgr-path
                  (lambda* (#:key inputs #:allow-other-keys)
                    (substitute* "grub-core/osdep/unix/platform.c"

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-18 16:20 ` Mark H Weaver
  2018-02-18 16:49   ` Danny Milosavljevic
@ 2018-02-20  3:21   ` Marius Bakke
  2018-02-20  3:46     ` Marius Bakke
  1 sibling, 1 reply; 19+ messages in thread
From: Marius Bakke @ 2018-02-20  3:21 UTC (permalink / raw)
  To: Mark H Weaver, 30311; +Cc: Ricardo Wurmus


[-- Attachment #1.1: Type: text/plain, Size: 671 bytes --]

Mark H Weaver <mhw@netris.org> writes:

> Hi Ricardo,
>
> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> writes:
>> Okay, I’ve added “--target=i386-pc” to the list of arguments.
>
> This change breaks my mips64el-linux GuixSD system, which is supported
> by GRUB, but where "--target=i386-pc" is obviously not appropriate.  On
> my system I need a different 'target' setting.

Maybe we can make it conditional on EFI for now.  Ricardo, are you able
to test the attached patch?  I suspect we might get problems on POWER
and some ARM systems down the road, but it should at least fix this
immediate issue.

Note: I haven't tested this patch myself.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Pass-target-to-EFI-less-GRUB-only-when-EFI-varia.patch --]
[-- Type: text/x-patch, Size: 1480 bytes --]

From ce5d6089aff0cf6c31260ac2bbe0aeb2803eb8a0 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Tue, 20 Feb 2018 04:02:23 +0100
Subject: [PATCH] gnu: Pass "--target" to EFI-less GRUB only when EFI variables
 are present.

Fixes <https://bugs.gnu.org/30311>.

* gnu/bootloader/grub.scm (install-grub): Make "--target" argument
conditional on the presence of "/sys/firmware/efi".
---
 gnu/bootloader/grub.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 3b01125c7..2b8458161 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -386,8 +386,13 @@ submenu \"GNU system, old configurations...\" {~%")
         ;; root partition.
         (setenv "GRUB_ENABLE_CRYPTODISK" "y")
 
-        (unless (zero? (system* grub "--no-floppy" "--target=i386-pc"
+        (unless (zero? (system* grub "--no-floppy"
                                 "--boot-directory" install-dir
+                                ;; Explicitly pass target if the non-EFI
+                                ;; GRUB is requested on an EFI system.
+                                ;; See <https://bugs.gnu.org/30311>.
+                                ,@(if (file-exists? "/sys/firmware/efi")
+                                      "--target=i386-pc")
                                 device))
           (error "failed to install GRUB (BIOS)")))))
 
-- 
2.16.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20  3:21   ` Marius Bakke
@ 2018-02-20  3:46     ` Marius Bakke
  2018-02-20 20:54       ` Danny Milosavljevic
  2018-02-20 21:00       ` Danny Milosavljevic
  0 siblings, 2 replies; 19+ messages in thread
From: Marius Bakke @ 2018-02-20  3:46 UTC (permalink / raw)
  To: Mark H Weaver, 30311; +Cc: Ricardo Wurmus


[-- Attachment #1.1: Type: text/plain, Size: 815 bytes --]

Marius Bakke <mbakke@fastmail.com> writes:

> Mark H Weaver <mhw@netris.org> writes:
>
>> Hi Ricardo,
>>
>> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> writes:
>>> Okay, I’ve added “--target=i386-pc” to the list of arguments.
>>
>> This change breaks my mips64el-linux GuixSD system, which is supported
>> by GRUB, but where "--target=i386-pc" is obviously not appropriate.  On
>> my system I need a different 'target' setting.
>
> Maybe we can make it conditional on EFI for now.  Ricardo, are you able
> to test the attached patch?  I suspect we might get problems on POWER
> and some ARM systems down the road, but it should at least fix this
> immediate issue.
>
> Note: I haven't tested this patch myself.

Bah, here is a fixed version that actually works (for the normal case).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Pass-target-to-EFI-less-GRUB-only-when-EFI-varia.patch --]
[-- Type: text/x-patch, Size: 1700 bytes --]

From 968ccb27e40ce683ec469f3ac7973827a7e8ddf5 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Tue, 20 Feb 2018 04:02:23 +0100
Subject: [PATCH] gnu: Pass "--target" to EFI-less GRUB only when EFI variables
 are present.

Fixes <https://bugs.gnu.org/30311>.

* gnu/bootloader/grub.scm (install-grub): Make "--target" argument
conditional on the presence of "/sys/firmware/efi".
---
 gnu/bootloader/grub.scm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 3b01125c7..17ded5f6d 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -386,9 +386,15 @@ submenu \"GNU system, old configurations...\" {~%")
         ;; root partition.
         (setenv "GRUB_ENABLE_CRYPTODISK" "y")
 
-        (unless (zero? (system* grub "--no-floppy" "--target=i386-pc"
-                                "--boot-directory" install-dir
-                                device))
+        (unless (zero? (apply system* grub
+                              (list "--no-floppy"
+                                    "--boot-directory" install-dir
+                                    ;; Explicitly pass target if the non-EFI
+                                    ;; GRUB is requested on an EFI system.
+                                    ;; See <https://bugs.gnu.org/30311>.
+                                    #$@(if (file-exists? "/sys/firmware/efi")
+                                           '("--target=i386-pc"))
+                                    device)))
           (error "failed to install GRUB (BIOS)")))))
 
 (define install-grub-efi
-- 
2.16.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20  3:46     ` Marius Bakke
@ 2018-02-20 20:54       ` Danny Milosavljevic
  2018-02-20 21:00       ` Danny Milosavljevic
  1 sibling, 0 replies; 19+ messages in thread
From: Danny Milosavljevic @ 2018-02-20 20:54 UTC (permalink / raw)
  To: Marius Bakke; +Cc: Ricardo Wurmus, 30311

Hi Marius,

hmm, if the conditional doesn't have an alternative case, doesn't that mean that the
value is unspecified?  The list constructor doesn't like that...

You probably meant '()

Other than that, I agree that something like this patch is the low-risk workaround
to do.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20  3:46     ` Marius Bakke
  2018-02-20 20:54       ` Danny Milosavljevic
@ 2018-02-20 21:00       ` Danny Milosavljevic
  2018-02-22 15:06         ` Marius Bakke
  1 sibling, 1 reply; 19+ messages in thread
From: Danny Milosavljevic @ 2018-02-20 21:00 UTC (permalink / raw)
  To: Marius Bakke; +Cc: Ricardo Wurmus, 30311

Also, grub-hybrid is supposed to use efi so the workaround shouldn't be used with it...

What do you think about my direct grub patch?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-18 16:49   ` Danny Milosavljevic
@ 2018-02-20 21:40     ` Ricardo Wurmus
  2018-02-20 21:43       ` Danny Milosavljevic
  0 siblings, 1 reply; 19+ messages in thread
From: Ricardo Wurmus @ 2018-02-20 21:40 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: Ricardo Wurmus, 30311


Hi Danny,

>> This change breaks my mips64el-linux GuixSD system, which is supported
>> by GRUB, but where "--target=i386-pc" is obviously not appropriate.  On
>> my system I need a different 'target' setting.
>
> A pretty safe workaround is to substitute /sys/firmware/efi by /sys/firmware/non-efi
> in ./grub-core/osdep/linux/platform.c for non-efi grub.

I don’t understand this patch.  How does it work?

What is the effect of replacing /sys/firmware/efi with
/sys/firmware/non-efi?

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20 21:40     ` Ricardo Wurmus
@ 2018-02-20 21:43       ` Danny Milosavljevic
  2018-02-20 21:49         ` Ricardo Wurmus
  0 siblings, 1 reply; 19+ messages in thread
From: Danny Milosavljevic @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Ricardo Wurmus, 30311

> I don’t understand this patch.  How does it work?
> 
> What is the effect of replacing /sys/firmware/efi with
> /sys/firmware/non-efi?

It won't find EFI since it's looking in the wrong place.

That's what we want :)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20 21:43       ` Danny Milosavljevic
@ 2018-02-20 21:49         ` Ricardo Wurmus
  2018-02-20 22:00           ` Danny Milosavljevic
  0 siblings, 1 reply; 19+ messages in thread
From: Ricardo Wurmus @ 2018-02-20 21:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: Ricardo Wurmus, 30311


Danny Milosavljevic <dannym@scratchpost.org> writes:

>> I don’t understand this patch.  How does it work?
>>
>> What is the effect of replacing /sys/firmware/efi with
>> /sys/firmware/non-efi?
>
> It won't find EFI since it's looking in the wrong place.
>
> That's what we want :)

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

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?

I’m thoroughly confused.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20 21:49         ` Ricardo Wurmus
@ 2018-02-20 22:00           ` Danny Milosavljevic
  2018-03-26 21:15             ` Danny Milosavljevic
  0 siblings, 1 reply; 19+ messages in thread
From: Danny Milosavljevic @ 2018-02-20 22:00 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Ricardo Wurmus, 30311

Hi Ricardo,

On Tue, 20 Feb 2018 22:49:19 +0100
Ricardo Wurmus <rekado@elephly.net> 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?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20 21:00       ` Danny Milosavljevic
@ 2018-02-22 15:06         ` Marius Bakke
  2018-02-22 15:47           ` Ricardo Wurmus
  0 siblings, 1 reply; 19+ messages in thread
From: Marius Bakke @ 2018-02-22 15:06 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: Ricardo Wurmus, 30311

[-- Attachment #1: Type: text/plain, Size: 673 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Also, grub-hybrid is supposed to use efi so the workaround shouldn't be used with it...

Right, I had forgotten about grub-hybrid.  That complicates things.

> What do you think about my direct grub patch?

That works too :-) It just felt a little "heavy-handed".  I'll let
Ricardo judge which approach to take.

I do wonder if we can do better though, and maybe even fix it properly.
Ricardo: Can you post the output of `find /sys/firmware/efi -maxdepth 1`
on the affected machine?  With luck, we'll find a variable that is only
present on "real" EFI.

Can you also post the contents of '/sys/firmware/efi/runtime'?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-22 15:06         ` Marius Bakke
@ 2018-02-22 15:47           ` Ricardo Wurmus
  2018-02-23 11:30             ` Marius Bakke
  0 siblings, 1 reply; 19+ messages in thread
From: Ricardo Wurmus @ 2018-02-22 15:47 UTC (permalink / raw)
  To: Marius Bakke; +Cc: Ricardo Wurmus, 30311


Marius Bakke <mbakke@fastmail.com> writes:

> Ricardo: Can you post the output of `find /sys/firmware/efi -maxdepth 1`
> on the affected machine?  With luck, we'll find a variable that is only
> present on "real" EFI.
>
> Can you also post the contents of '/sys/firmware/efi/runtime'?

Now that I have GuixSD installed on that machine I don’t have
/sys/firmware/efi at all.  /sys/firmware contains “acpi”, “dmi”, and
“memmap” only.

The problem occurred when I tried to install GuixSD (after booting from
a GuixSD installer USB drive), not when reconfiguring.  I don’t have a
USB drive with me at the moment, so I cannot check the contents of
/sys/firmware in the installer GuixSD now.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-22 15:47           ` Ricardo Wurmus
@ 2018-02-23 11:30             ` Marius Bakke
  0 siblings, 0 replies; 19+ messages in thread
From: Marius Bakke @ 2018-02-23 11:30 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Ricardo Wurmus, 30311

[-- Attachment #1: Type: text/plain, Size: 980 bytes --]

Ricardo Wurmus <rekado@elephly.net> writes:

> Marius Bakke <mbakke@fastmail.com> writes:
>
>> Ricardo: Can you post the output of `find /sys/firmware/efi -maxdepth 1`
>> on the affected machine?  With luck, we'll find a variable that is only
>> present on "real" EFI.
>>
>> Can you also post the contents of '/sys/firmware/efi/runtime'?
>
> Now that I have GuixSD installed on that machine I don’t have
> /sys/firmware/efi at all.  /sys/firmware contains “acpi”, “dmi”, and
> “memmap” only.
>
> The problem occurred when I tried to install GuixSD (after booting from
> a GuixSD installer USB drive), not when reconfiguring.  I don’t have a
> USB drive with me at the moment, so I cannot check the contents of
> /sys/firmware in the installer GuixSD now.

In this case I'm certain that the installer booted in EFI mode, crushing
my dreams of a proper fix.  So we'll need one of the proposed
workarounds to prevent this problem in the future.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#30311: efi-less grub install fails
  2018-02-20 22:00           ` Danny Milosavljevic
@ 2018-03-26 21:15             ` Danny Milosavljevic
  0 siblings, 0 replies; 19+ messages in thread
From: Danny Milosavljevic @ 2018-03-26 21:15 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Ricardo Wurmus, 30311

[-- Attachment #1: Type: text/plain, Size: 2115 bytes --]

Any news on how to proceed on this grub target thing?

I think the patch below is harmless enough and makes each grub package
self-consistent (the non-efi grub doesn't try to use efi, the grub-efi
tries to use efi and grub-hybrid tries to use efi, then).

From 263b1dc0de9643094bc41f4be47b4b2317e95d7c Mon Sep 17 00:00:00 2001
From: Danny Milosavljevic <dannym@scratchpost.org>
Date: Sun, 18 Feb 2018 17:30:48 +0100
Subject: [PATCH] gnu: grub: Make sure that non-EFI grub doesn't try to use
 EFI.
Tags: patch

* gnu/packages/bootloader.scm (grub)[arguments]<:phases>
[patch-/sys/firmware/efi-out]: New phase.
(grub-efi)[arguments]<:phases>[patch-/sys/firmware/efi-out]: Delete phase.

Fixes <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30311>.
---
 gnu/packages/bootloaders.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 59eb22f24..c09829e17 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -103,6 +103,11 @@
                      (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
                      (system* "gunzip" "unifont.bdf.gz")
                      #t))
+                  (add-after 'unpack 'patch-/sys/firmware/efi-out
+                   (lambda _
+                     (substitute* "grub-core/osdep/linux/platform.c"
+                      (("/sys/firmware/efi") "/sys/firmware/non-efi"))
+                     #t))
                   (add-before 'check 'disable-flaky-test
                     (lambda _
                       ;; This test is unreliable. For more information, see:
@@ -177,6 +182,7 @@ menu to select one of the installed operating systems.")
             `(cons "--with-platform=efi" ,flags))
            ((#:phases phases)
             `(modify-phases ,phases
+               (delete 'patch-/sys/firmware/efi-out)
                (add-after 'patch-stuff 'use-absolute-efibootmgr-path
                  (lambda* (#:key inputs #:allow-other-keys)
                    (substitute* "grub-core/osdep/unix/platform.c"

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-03-26 21:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 18:55 bug#30311: efi-less grub install fails Ricardo Wurmus
2018-01-31 23:34 ` Danny Milosavljevic
2018-02-01 12:40   ` Marius Bakke
2018-02-18 11:28     ` Ricardo Wurmus
2018-01-31 23:55 ` Ludovic Courtès
2018-02-18 16:20 ` Mark H Weaver
2018-02-18 16:49   ` Danny Milosavljevic
2018-02-20 21:40     ` Ricardo Wurmus
2018-02-20 21:43       ` Danny Milosavljevic
2018-02-20 21:49         ` Ricardo Wurmus
2018-02-20 22:00           ` Danny Milosavljevic
2018-03-26 21:15             ` Danny Milosavljevic
2018-02-20  3:21   ` Marius Bakke
2018-02-20  3:46     ` Marius Bakke
2018-02-20 20:54       ` Danny Milosavljevic
2018-02-20 21:00       ` Danny Milosavljevic
2018-02-22 15:06         ` Marius Bakke
2018-02-22 15:47           ` Ricardo Wurmus
2018-02-23 11:30             ` Marius Bakke

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).