all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it.
@ 2017-07-14 18:59 Danny Milosavljevic
  2017-07-14 19:01 ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Danny Milosavljevic
  2017-07-14 19:34 ` [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic
  0 siblings, 2 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-14 18:59 UTC (permalink / raw)
  To: 27695

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(-)

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

* [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
  2017-07-14 18:59 [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic
@ 2017-07-14 19:01 ` Danny Milosavljevic
  2017-07-14 19:01   ` [bug#27695] [PATCH 2/2] install: Use grub-hybrid-bootloader Danny Milosavljevic
  2017-07-20  8:39   ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Ludovic Courtès
  2017-07-14 19:34 ` [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic
  1 sibling, 2 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-14 19:01 UTC (permalink / raw)
  To: 27695

* 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)))
+
 \f
 ;;;
 ;;; 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

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

* [bug#27695] [PATCH 2/2] install: Use grub-hybrid-bootloader.
  2017-07-14 19:01 ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Danny Milosavljevic
@ 2017-07-14 19:01   ` Danny Milosavljevic
  2017-07-20  8:39   ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Ludovic Courtès
  1 sibling, 0 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-14 19:01 UTC (permalink / raw)
  To: 27695

* 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

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

* [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it.
  2017-07-14 18:59 [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic
  2017-07-14 19:01 ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Danny Milosavljevic
@ 2017-07-14 19:34 ` Danny Milosavljevic
  1 sibling, 0 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-14 19:34 UTC (permalink / raw)
  To: 27695

On Fri, 14 Jul 2017 20:59:54 +0200
Danny Milosavljevic <dannym@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.

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

* [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
  2017-07-14 19:01 ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Danny Milosavljevic
  2017-07-14 19:01   ` [bug#27695] [PATCH 2/2] install: Use grub-hybrid-bootloader Danny Milosavljevic
@ 2017-07-20  8:39   ` Ludovic Courtès
  2017-07-20 11:47     ` Danny Milosavljevic
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2017-07-20  8:39 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 27695

Hi,

Danny Milosavljevic <dannym@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’.

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

* [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
  2017-07-20  8:39   ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Ludovic Courtès
@ 2017-07-20 11:47     ` Danny Milosavljevic
  2017-07-20 18:42       ` Danny Milosavljevic
  0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-20 11:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27695

Hi Ludo,

On Thu, 20 Jul 2017 10:39:14 +0200
ludo@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*.

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

* [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.
  2017-07-20 11:47     ` Danny Milosavljevic
@ 2017-07-20 18:42       ` Danny Milosavljevic
  0 siblings, 0 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2017-07-20 18:42 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27695

> 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.

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

end of thread, other threads:[~2017-07-20 18:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-14 18:59 [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic
2017-07-14 19:01 ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Danny Milosavljevic
2017-07-14 19:01   ` [bug#27695] [PATCH 2/2] install: Use grub-hybrid-bootloader Danny Milosavljevic
2017-07-20  8:39   ` [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader Ludovic Courtès
2017-07-20 11:47     ` Danny Milosavljevic
2017-07-20 18:42       ` Danny Milosavljevic
2017-07-14 19:34 ` [bug#27695] [PATCH 0/2] Introduce grub hybrid bootloader and use it Danny Milosavljevic

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.