[lfs-support] Almost Finished with Grub and EFI--But First Some Basics

Dan McGhee beesnees at grm.net
Wed Nov 13 16:00:59 PST 2013

I'm in the final stages of building and installing GRUB so that it works 
in an EFI environment.  It's been quite interesting and I'm looking 
forward to sharing what I have done on this list.  However, before I do 
that, I need to say that I'm not "quite" done yet.  I still have not yet 
gotten my LFS build to boot, but am honing in on the solution.

I have learned from my reading that some of the "problems" people 
encounter in trying to do this may be hardware related.  Therefore, it's 
a distinct possibility that my experience and procedure may need to be 
modified when someone else wants to do the same thing. With that caveat, 
let me describe what I can and can't do and then pose my current questions.

I can boot anything I want in "EFI Mode", except LFS-7.4, directly from 
booting or from a grub.cfg for a different linux system.  What I haven't 
been able to do is boot something through what we may look at as GRUB's 
way--from the grub.cfg with entries as:

set root='hdX, gptY'
echo "Booting LFS-7.4......."
linux /boot/vimluz*-lfs-7.4 ro

To boot Ubuntu from the grub.cfg that I use for LFS-7.4, and vice versa, 
I must "chainload" it.  This is the part that I do not know whether it's 
determined by firmware or my level of knowledge.  If it's the latter, 
I'll get it figured out sooner or later.  And just for the record, I 
have not as yet gotten a kernel to boot using its efi-stubs--but it was 
my LFS-7.4 kernel which may not be bootable. Now I'd like comments on my 
understanding of the boot process.

GRUB starts and looks for it's config file.  It executes video and font 
commands and loads the kernel.  The kernel then mounts the file system 
as "read only" and runs fsck. Then it mounts the file system in 
"read,write" and goes through its sequence then hands off to the rc.init 
functions.  Is this correct so far?

If this is correct, shouldn't I see something from the kernel almost 
immediately after I see "Booting LFS-7.4....." When I start getting 
those pretty green "OK's," or the Ubuntu splash screen, then I know that 
SysVinit has taken over.

What has happened in trying to go from the LFS-menu to boot Ubuntu or 
Ubuntu-menu to boot LFS, using GRUB's way, I get a blank screen and must 
do a "hard reset."  This happens when grub.cfg is in /boot/grub or on 
the EFI partition at EFI/lfs-7.4/grub.  Thinking that since this is 
"before" the filesystem gets mounted, GRUB doesn't have the geometry to 
know where /boot/grub/grub.cfg is, I made a grub image that looked for 
its config file in same directory as the image and used this as 
grub.cfg--this is the way Ubuntu does it:

search.fs_uuid [UUID for /dev/sda6] root hd0,gpt6
set prefix=($root)/boot/grub
configfile $prefix/grub.cfg

When this booted, I got the grub shell.  I entered what I thought were 
appropriate commands and got the message: No suitable video mode found, 
booting in blind mode--and then nothing else.  Then I went to bed.

Since I got that message, I'm guessing that GRUB hadn't found 
/dev/sda6/boot/grub/grub.cfg yet.  When I ran <ls> in the grub shell, I 
got  listing for the top level of my partition.  I still don't know if 
my kernel is bootable, but, since I can't "get in to or out of" the LFS 
partition with /boot/grub/grub.cfg for either Ubuntu or LFS, I'm 
wondering if there's a problem with my partition.  The other thing I 
have discovered is that in an EFI environment efivarfs must be mounted 
to manipultate the efi variables.  I don't think I built grub before I 
learned that.  So rebuilding it is my next step.

But in the meantime, here's the command I used to make the image:

grub-mkimage -O x86_64-efi -o grubx64.efi -p "" part_gpt fat ext2 normal 
chain boot configfile linux multiboot

Does anyone see any more modules that I need?  Since, when I set up to 
use /boot/grub/grub.cfg directly from grubx64.efi, I get the results of 
the echo command, is this the signal that grub has done it's job and has 
loaded the kernel?  If there was a problem with my partition, would I 
get a message or just a "freeze?" If all is "normal," should I get a 
kernel message or splash screen almost immediately after the results of 
<echo>.  And, unless tty's are misconfigured, should I get a "kernel 
panic?"  (Sorry for these really basic questions, but the rust layer is 
deeper than I thought it was.)

I'm still trying to determine where my efforts should be directed to 
find out what kind of problem I have.  I can run <fsck> on an umounted 
/dev/sda6 from Ubuntu and rebuild grub with efivarfs mounted in chroot.  
Other than that I'd like to get some suggestions.


More information about the lfs-support mailing list