GNU bug report logs - #27695
[PATCH 0/2] Introduce grub hybrid bootloader and use it.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Fri, 14 Jul 2017 19:01:01 UTC

Severity: normal

Tags: patch

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27695 in the body.
You can then email your comments to 27695 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Fri, 14 Jul 2017 19:01:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 14 Jul 2017 19:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 0/2] Introduce grub hybrid bootloader and use it.
Date: Fri, 14 Jul 2017 20:59:54 +0200
Ok, it turns out that grub-mkrescue can create a hybrid bootloader that works
with both EFI and non-EFI systems.

For that, the contents of lib/grub/i386-pc has to be available to
grub-mkrescue.  Then it will build a hybrid bootloader.

I've successfully tested it using:

$ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -cdrom ZZ -serial stdio
$ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -hda ZZ -serial stdio
$ qemu-system-x86_64 -m 1G -enable-kvm -cdrom ZZ -serial stdio
$ qemu-system-x86_64 -m 1G -enable-kvm -hda ZZ -serial stdio

and the patch from bug# 27690.

Danny Milosavljevic (2):
  bootloader: Add grub-hybrid-bootloader.
  install: Use grub-hybrid-bootloader.

 gnu/bootloader/grub.scm      |  7 +++++++
 gnu/packages/bootloaders.scm | 20 ++++++++++++++++++++
 gnu/system/install.scm       |  3 ++-
 3 files changed, 29 insertions(+), 1 deletion(-)





Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Fri, 14 Jul 2017 19:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 27695 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
Date: Fri, 14 Jul 2017 21:01:56 +0200
* gnu/packages/bootloaders.scm (grub-hybrid): New variable.
* gnu/bootloader/grub.scm (grub-hybrid-bootloader): New variable.
---
 gnu/bootloader/grub.scm      |  7 +++++++
 gnu/packages/bootloaders.scm | 20 ++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 880491c98..a67d914ef 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -55,6 +55,7 @@
 
             grub-bootloader
             grub-efi-bootloader
+            grub-hybrid-bootloader
 
             grub-configuration))
 
@@ -413,6 +414,12 @@ submenu \"GNU system, old configurations...\" {~%")
    (name 'grub-efi)
    (package grub-efi)))
 
+(define* grub-hybrid-bootloader
+  (bootloader
+   (inherit grub-bootloader)
+   (name 'grub-hybrid)
+   (package grub-hybrid)))
+
 
 ;;;
 ;;; Compatibility macros.
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 9c6927f2a..946bdfd9b 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -182,6 +182,26 @@ menu to select one of the installed operating systems.")
                                        "/bin/mcopy\"")))
                      #t))))))))))
 
+(define-public grub-hybrid
+  (package
+    (inherit grub-efi)
+    (name "grub-hybrid")
+    (synopsis "GRand Unified Boot loader (Hybrid version)")
+    (native-inputs
+     `(("grub" ,grub)
+       ,@(package-native-inputs grub-efi)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments grub-efi)
+      ((#:phases phases)
+      `(modify-phases ,phases
+         (add-after 'install 'install-non-efi
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (copy-recursively (string-append (assoc-ref inputs "grub")
+                                              "/lib/grub/i386-pc")
+                               (string-append (assoc-ref outputs "out")
+                                              "/lib/grub/i386-pc"))
+             #t))))))))
+
 (define-public syslinux
   (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
     (package




Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Fri, 14 Jul 2017 19:03:03 GMT) Full text and rfc822 format available.

Message #11 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 27695 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH 2/2] install: Use grub-hybrid-bootloader.
Date: Fri, 14 Jul 2017 21:01:57 +0200
* gnu/system/install.scm (installation-os): Use grub-hybrid-bootloader.
---
 gnu/system/install.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index f9aa7f673..ea4c40511 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -299,7 +299,8 @@ Use Alt-F2 for documentation.
     (host-name "gnu")
     (timezone "Europe/Paris")
     (locale "en_US.utf8")
-    (bootloader (grub-configuration
+    (bootloader (bootloader-configuration
+                 (bootloader grub-hybrid-bootloader)
                  (device "/dev/sda")))
     (file-systems
      ;; Note: the disk image build code overrides this root file system with




Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Fri, 14 Jul 2017 19:36:01 GMT) Full text and rfc822 format available.

Message #14 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 27695 <at> debbugs.gnu.org
Subject: Re: [PATCH 0/2] Introduce grub hybrid bootloader and use it.
Date: Fri, 14 Jul 2017 21:34:57 +0200
On Fri, 14 Jul 2017 20:59:54 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> wrote:

> Ok, it turns out that grub-mkrescue can create a hybrid bootloader that works
> with both EFI and non-EFI systems.
> 
> For that, the contents of lib/grub/i386-pc has to be available to
> grub-mkrescue.  Then it will build a hybrid bootloader.
> 
> I've successfully tested it using:
> 
> $ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -cdrom ZZ -serial stdio
> $ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -hda ZZ -serial stdio
> $ qemu-system-x86_64 -m 1G -enable-kvm -cdrom ZZ -serial stdio
> $ qemu-system-x86_64 -m 1G -enable-kvm -hda ZZ -serial stdio
> 
> and the patch from bug# 27690.

and the patch from bug# 27689.

To clarify: I've tested both

$ guix system disk-image gnu/system/install.scm

and

$ guix system disk-image -t iso9660 gnu/system/install.scm

- both successfully.




Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Thu, 20 Jul 2017 08:40:01 GMT) Full text and rfc822 format available.

Message #17 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 27695 <at> debbugs.gnu.org
Subject: Re: [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
Date: Thu, 20 Jul 2017 10:39:14 +0200
Hi,

Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> * gnu/packages/bootloaders.scm (grub-hybrid): New variable.
> * gnu/bootloader/grub.scm (grub-hybrid-bootloader): New variable.

[...]

> +(define-public grub-hybrid
> +  (package
> +    (inherit grub-efi)
> +    (name "grub-hybrid")
> +    (synopsis "GRand Unified Boot loader (Hybrid version)")
                                             ^
Lower-case please.

> +    (native-inputs
> +     `(("grub" ,grub)
> +       ,@(package-native-inputs grub-efi)))
> +    (arguments
> +     (substitute-keyword-arguments (package-arguments grub-efi)
> +      ((#:phases phases)
> +      `(modify-phases ,phases
> +         (add-after 'install 'install-non-efi
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (copy-recursively (string-append (assoc-ref inputs "grub")
> +                                              "/lib/grub/i386-pc")
> +                               (string-append (assoc-ref outputs "out")
> +                                              "/lib/grub/i386-pc"))
> +             #t))))))))

Is it really all it takes to make a GRUB that can do both BIOS and UEFI?
I wonder why GRUB upstream doesn’t do it by default.  Do you think we
should discuss it with them?

If that works, we might just as well make it the new “grub” package and
remove “grub-efi”.  Or is there any downside?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Thu, 20 Jul 2017 11:48:02 GMT) Full text and rfc822 format available.

Message #20 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 27695 <at> debbugs.gnu.org
Subject: Re: [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
Date: Thu, 20 Jul 2017 13:47:32 +0200
Hi Ludo,

On Thu, 20 Jul 2017 10:39:14 +0200
ludo <at> gnu.org (Ludovic Courtès) wrote:

> Is it really all it takes to make a GRUB that can do both BIOS and UEFI?
> I wonder why GRUB upstream doesn’t do it by default.

I think they do, in a sense.  In many other distributions the directory is common - so if you install both grub-pc and grub-efi on your disk then grub will indeed use both (for grub-mkrescue).

>  Do you think we should discuss it with them?
> 
> If that works, we might just as well make it the new “grub” package and
> remove “grub-efi”.  Or is there any downside?

I only use this feature for grub-mkrescue right now.  I know that it is supported *there* in the sense that there's explicit "if" blocks checking for both platforms (by literals) in the same function, but not exclusively (i.e. "if (efi) A; if (non efi) B;" without "else").  See main() in util/grub-mkrescue.c in grub 2.02 (lines 667ff for EFI, lines 571ff for "PC"). The EFI stuff has "_EFI" in the preprocessor definitions, so search for that.

Note that main() supports a command line option for getting the source files for ONE SINGLE platform, but when you don't specify that option then it uses multiple platforms (the ones it can find).

For using multiple platforms as a regular bootloader I do NOT know whether that works or makes sense at all.  Maybe it does, I just didn't test it (and can't usefully).

That's why there's the alternative implementation that wouldn't add a Guix bootloader for it.

I hope someone else knows.  I don't have EFI hardware so I'm really the wrong person to find out that stuff.  Well I could try reading the documentation / asking and hoping that it's all correct, but ... you know... paper is patient :)

util/grub-install.c seems to use a case anaylsis with exclusive cases for finding out EFI or not *shrugs*.




Information forwarded to guix-patches <at> gnu.org:
bug#27695; Package guix-patches. (Thu, 20 Jul 2017 18:43:02 GMT) Full text and rfc822 format available.

Message #23 received at 27695 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 27695 <at> debbugs.gnu.org
Subject: Re: [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
Date: Thu, 20 Jul 2017 20:42:07 +0200
> I hope someone else knows.  I don't have EFI hardware so I'm really the wrong person to find out that stuff.  Well I could try reading the documentation / asking and hoping that it's all correct, but ... you know... paper is patient :)

I read up on EFI some more.  Apparently EFI can load files from FAT partitions and execute them.

There's the tool "grub-mkstandalone" which will put the GRUB bootloader into an executable file that you can then put on the FAT partition - which the EFI system will later boot from.

So I guess we already do all that's required for installed-hybrid support because Marius already added the grub-mkstandalone invocation to gnu/build/vm.scm - and we install the traditional grub-pc otherwise.  So isn't it already hybrid?  Can't be far off.

Maybe I contributed to the confusion, but my meddling with grub-efi and grub-hybrid is really just to have grub-mkrescue build a hybrid ISO, nothing else.  I don't use grub-install at all there (and I don't use grub-mkstandalone either).

I think the best way forward for the ISO image to do it like that:
* Add grub-hybrid to (gnu packages bootloaders) - but don't add a (gnu bootloaders) entry.  Don't use grub-hybrid for anything except when creating the ISO image.
* Either make gnu/system/install.scm directly depend on grub-hybrid as "bootloader" package - or just have make-iso9660-image always override it by grub-hybrid. 

That's it.  I don't think we have to fiddle with the regular Guix bootloaders or even with the existing bootloader packages at all.




bug closed, send any further explanations to 27695 <at> debbugs.gnu.org and Danny Milosavljevic <dannym <at> scratchpost.org> Request was from Danny Milosavljevic <dannym <at> scratchpost.org> to control <at> debbugs.gnu.org. (Sat, 23 Dec 2017 22:17:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 21 Jan 2018 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 96 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.