Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 308385

Summary: sys-boot/grub-2 multiple platform support
Product: Gentoo Linux Reporter: Benedikt Reinartz <filmor>
Component: New packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: enhancement CC: aklhfex, akshayushah, amigadave, darkbasic, flow, ford_prefect, lephilousophe, o.freyermuth, panard, pemagongo
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch for the ebuild

Description Benedikt Reinartz 2010-03-07 21:32:47 UTC
Grub 2 has support for EFI, yet the ebuild doesn't support it and just builds the BIOS variant. I'd really like to have a proper EFI installation in portage, preferably enabled by USE=efi.

This is already implemented in Bug #291851.

Reproducible: Always

Steps to Reproduce:
1. emerge >grub-1
Actual Results:  
Builds the BIOS version on x86.

Expected Results:  
Build the EFI version.
Comment 1 Rafał Mużyło 2010-03-08 11:15:38 UTC
*** Bug 308389 has been marked as a duplicate of this bug. ***
Comment 2 SpanKY gentoo-dev 2010-03-29 05:52:28 UTC
i dont have any EFI systems, so i really have no way of testing things

what exactly do you need changed in the ebuild ?  --enable-efiemu ?
Comment 3 Benedikt Reinartz 2010-03-29 17:05:48 UTC
Nope, it's "--with-platform=efi". The rest should be quite similar to the bios version. You make an grub.efi with grub-mkimage and toss it into your boot partitions /EFI directory together with modules and grub.cfg.
Comment 4 SpanKY gentoo-dev 2010-03-30 22:16:10 UTC
i see that the platform option can actually support multiple things: pc, efi, coreboot, ieee1275, qemu, ...

some of these make sense to have enabled in parallel.  i wonder if we should make this into a USE_EXPANDED variable so that people could select multiple things at once.  if the user hasnt selected any at all, then we'd default to both pc and efi on x86/x86_64 ...
Comment 5 Benedikt Reinartz 2010-05-08 09:45:21 UTC
So, is there going to be such a use variable? The grub-2 ebuild is quite useless without it as grub-2 in this form is not really better than grub-1 on x86...
Comment 6 SpanKY gentoo-dev 2010-05-10 05:22:30 UTC
ebuild updates dont appear out of thin air.  someone has to do the work.
Comment 7 Benedikt Reinartz 2010-05-10 07:23:07 UTC
Created attachment 230923 [details, diff]
Patch for the ebuild

Sorry, I didn't know if you were working on this. I don't know where you've read that one can use multiple platforms, the autoconf-script suggests that you can only have enabled one platform at a time. As the automatic works in most cases (and nobody complained yet) the only thing that needs to be added is an efi useflag, as on Intel Macs and other x86-EFI-environments the configure-scripts only sees the x86-part and chooses the bios-platform.
Comment 8 SpanKY gentoo-dev 2010-05-12 05:56:42 UTC
no, i havent been working on it.  sorry if that wasnt clear.  i was merely tossing out ideas.

if we're going to spend time on this, i'd rather we fix it once and be done.  unless i missed something, i believe x86 supports multiple targets (as i mentioned in comment #4).  so we'd want to declare a new USE_EXPAND.

let's go with:
 - USE_EXPAND variable name is GRUB_PLATFORMS
 - ebuild has IUSE_GRUB_PLATFORMS="coreboot efi emu ieee1275 pc qemu yeeloong"
 - if user hasnt selected any platforms, we default to all the valid values for the target cpu
 - src_compile does a for loop over the possible values and runs configure/make in a sep build dir with platform set for each enabled value
 - src_install does a for loop over the possible values and installs from the sep build dir for each enabled value

i wont have time to implement this for a while.  see the sandbox ebuild as an example of multiple configures+makes.
Comment 9 darkbasic 2011-03-20 14:32:54 UTC
I think it's starting to be quite important to support efi because sandy bridge motherboards use it.
I have a Core i5 2500K with H67 chipset so I can test it if patches are proposed.
Comment 10 LiuCougar 2011-04-24 03:25:29 UTC
(In reply to comment #8)
> if we're going to spend time on this, i'd rather we fix it once and be done. 
> unless i missed something, i believe x86 supports multiple targets (as i
> mentioned in comment #4).  so we'd want to declare a new USE_EXPAND.
AFAICT, grub2 does not support building multiple platforms. if multiple --with-patlform is given to configure script, the last one is chosen. so it looks like we don't need a USE_EXPAND
Comment 11 Oliver Freyermuth 2011-04-26 07:01:36 UTC
As a quick workaround, copying the ebuild to a local overlay and adding "--with-platform=efi" manually worked perfectly. 
I can boot my P8P67 Deluxe fine with it, just copied over the efi-builds to the efi system partition, loaded once with efi-shell and used efibootmgr to add it to the bootup-options. 
Great working alternative to elilo, I mainly used this tutorial: 
http://grub.enbug.org/TestingOnUEFI (page currently offline, but available via Google Cache). 
Maybe the ebuild should also automate the copy-over part of the .efi-files to the correct directory and / or the efibootmgr-setup.
Comment 12 SpanKY gentoo-dev 2011-04-26 07:26:29 UTC
(In reply to comment #10)

you snipped a fairly important part of my comment #8 ... specifically, where i said "run a loop" which means "configure/compile grub multiple times; once for each requested platform"
Comment 13 PeMaGonGo 2011-05-19 20:14:00 UTC
(In reply to comment #11)
> As a quick workaround, copying the ebuild to a local overlay and adding
> "--with-platform=efi" manually worked perfectly. 
> I can boot my P8P67 Deluxe fine with it, just copied over the efi-builds to the
> efi system partition, loaded once with efi-shell and used efibootmgr to add it
> to the bootup-options. 
> Great working alternative to elilo, I mainly used this tutorial: 
> http://grub.enbug.org/TestingOnUEFI (page currently offline, but available via
> Google Cache). 
> Maybe the ebuild should also automate the copy-over part of the .efi-files to
> the correct directory and / or the efibootmgr-setup.

unfortunately the cache was cleaned up and the tut is gone... I tried the tut on https://wiki.archlinux.org/index.php/GRUB2#Bootloader_Installation_for_UEFI_systems

but couldn't make it working yet... could you please somehow reproduce the how-to?
Comment 14 Oliver Freyermuth 2011-05-19 20:27:21 UTC
The page is now conserved here (also as a reference on how to implement the new ebuild sometime): 
https://help.ubuntu.com/community/UEFIBooting
(a copy of the original page)
However, it mainly consists of the copy-over-part and on the generation of the correct partitions. 
To get your system to boot in UEFI-Mode once: Read the "Miscellaneous info"-section or use an UEFI-enabled linux-distribution (new Ubuntu Live CD might do the trick). This should then become a NOTICE in the ebuild. 
In long-term view, UEFI-booting should also be integrated in the Gentoo-Live oder Minimal CD. But I have not tested whether the IA64-disk already supports it (it might, for UEFI came here a lot earlier).
Comment 15 Tomáš Chvátal (RETIRED) gentoo-dev 2011-05-30 13:22:18 UTC
This functionality is implemented in my dev overlay.

Only thing that is lacking now is some detection script which platforms what cpu supports. (so we won't get configure/build failiures if user set stupid platforms to be enabled).
Comment 17 Philippe Valembois 2011-06-25 19:22:36 UTC
It seems that the Grub ebuild in Scarabeus overlay is broken : the modules are stripped and they shouldn't be.
I think there is a typo in -9999 and 1.99 ebuilds : the STRIP_MASK variable ends with a "a" and shouldn't.
Applying this patch worked for me :

--- a/sys-boot/grub/grub-1.99.ebuild
+++ b/sys-boot/grub/grub-1.99.ebuild
@@ -63,7 +63,7 @@ else
        DEPEND+=" app-arch/xz-utils"
 fi
 
-export STRIP_MASK="*/grub/*/*.{mod,img}a"
+export STRIP_MASK="*/grub/*/*.{mod,img}"
 QA_EXECSTACK="
        lib64/grub/*/setjmp.mod
        lib64/grub/*/kernel.img
Comment 18 Florian Schmaus gentoo-dev 2011-06-30 14:04:31 UTC
In addition to the "a" in STRIP_MASK, I had to comment out the lines 227 and 228 in the 1.99 ebuild, to get grub emerged on a fresh stage3 install:

    227 #       grub_rename_files deep "${ED}"/usr/share/man/man1/
    228 #       grub_rename_files deep "${ED}"/usr/share/man/man8/

But everything else worked and I am now able to boot via UEFI and grub on my X220.
Comment 19 Tomáš Chvátal (RETIRED) gentoo-dev 2011-08-27 13:43:21 UTC
Added the grub with GRUB_PLATFORMS support into main tree.