[lfs-support] Grub and UEFI--very limited success

Dan McGhee beesnees at grm.net
Fri Sep 26 15:17:09 PDT 2014

I keep posting these to lfs-support because the subject involves 
configuring, building and installing grub, Ch.'s 6 and 8.  This process 
does, however, involve building and installing two BLFS 
packages--pciutils and popt--and three non-{,B}LFS packages--dosfstools, 
efivar and efibootmgr.

And I don't even know why I'm posting this.  I have no specific 
questions.  I can only hope that someone can see a flaw in what I've 
done or can ask "Did you think of this....." questions.

My goal has been "boot LFS from UEFI firmware using only Grub2 built in 
LFS"  This is only for x86_64 systems shipped with Win 8.x. x86_64 UEFI 
systems and 32-bit systems with Win 7 and before didn't have to deal 
with Secure Boot and the associated EFI variables. Setting up this way 
would be easier on one of those, I think.

My limited success is that I get to "Loading Linux <kernel name>....." 
from Grub and then booting freezes and ALT-CTRL-DEL is the only thing I 
can do.  This is true for LFS-7.4. LFS-7.5 and Ubuntu.

My Ubuntu--14.04, I think--install put a grubx64.efi image on the EFI 
partition.  Based on the statement

> cd <grub2_compiled_source_dir>/grub-core
> ../grub-mkimage -O ${EFI_ARCH}-efi -d . -o grub.efi -p "" part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot configfile linux multiboot
> sudo cp grub.efi *.mod *.lst /mnt/EFISYS/efi/grub
from this Ubuntu document: 

I reasoned that my ubuntu grub image was done this way.  In the same 
directory in which the grub image resides there is a grub.cfg file that 
sets the root partition, points at /boot/grub in that partition and then 
uses "configfile" to load the grub.cfg from /boot/grub.  I "hacked" this 
file to point at my LFS-7.5 partition and booted. Everything worked 
great for all three of the kernels that I mentioned above.

Since this worked, everything in all my partitions is OK.  It's only 
Grub on the EFI partition that is giving the problem.  There are two 
issues:  1) my grub for LFS-7.5 or the resulting grub image needs 
tweaking, or 2) there's something in the grub image-EFI interface that's 
preventing Grub from "reaching across" the partitions.  This is the 
point at which I have run out of ideas.  Maybe the grub experts here 
could give me some troubleshooting ideas. Documentation at this point is 

To get to this point here's how I configured grub:

> ./configure --prefix=/usr  \
>             --sbindir=/sbin        \
>             --sysconfdir=/etc      \
>             --disable-grub-emu-usb \
>             --disable-efiemu       \
>             --enable-grub-mkfont   \
>             --enable-device-mapper \
>             --with-platform=efi    \
>             --target=x86_64        \
>             --program-prefix=""    \
>             --with-bootdir="/boot" \
>             --with-grubdir="grub" \
>             --disable-werror
the options "--target=x86_64 --with-platform=efi" are mandatory for the 
EFI partition stuff.

To install grub to the EFI partition and populate /boot/grub I used:

> grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=LFS_Grub --recheck --debug

taken from this 

What I'm trying to do is very similar to the /boot partition described 
in LFS-Ch.8, using the EFI partition as /boot, with one modification.  I 
want the kernels to reside only on their own partitions to not 
over-populate the EFI partition. I've tried gummiboot and it works fine, 
but it needs the kernel, with efi-stub configure, on the EFI partition.  
I haven't tried rEFInd yet, but in reading its documentation the kernels 
must be on the EFI partition or in separate directories of a partition 
dedicated only to kernels.

The gummiboot and rEFInd images reside on the EFI partition, and, as I 
said gummiboot works fine.  My question is, "Why can't I do the same 
thing with the OS Boot Manager that gummiboot and rEFInd do?"

I discovered the grub-mkstandalone command.  This seems the way to go in 
the future.  Maybe I'm barking up the wrong tree, but I'd like to get a 
grub, that I built, working in the "normal" way.  I'm actually there now 
since I hacked the ubuntu grub.cfg.  I don't want to keep a distro 
around just to use one file, though.  I could nuke my Ubuntu and leave 
its grub on the EFI partition to find out.  That seems drastic and I 
just thought of it.  I can still get to the OS manager on boot to access 
my linux systems.  I guess it's just a matter of courage to do it.

Another avenue that I could explore is installing ARCH.  I've taken a 
lot of my stuff from the wiki there.  The "grub-install" command section 
is written as if everything works.  Maybe in installing ARCH I'll find 
something that I can use for what I really want to do.

I have purposefully refrained from talking about kernel configuration, 
and building those packages from outside LFS.  If anyone is interested, 
I'd be more than happy to post the info here.

On to LFS-7.6!

Thanks for the patience to read this far.


More information about the lfs-support mailing list