[lfs-support] GRUB2 Nuts and Bolts

Dan McGhee beesnees at grm.net
Thu Nov 7 11:20:33 PST 2013


This is not a rant or "finger pointing" session, I have a statement and 
some questions about GRUB2 options both in building it and installing it.

I have found no real useful information describing how to configure 
GRUB2 or in using grub-install.  Anything I've been able to try or 
further research comes from <./configure --help>, <grub-install --help> 
and <grub-mkimage --help>.  I've also opened grub-install and read it to 
find out some of what I want to know.  The currently available "GRUB 
Manual" goes only so far as grub-2.00-rc-1 and was written in Jun 2012.  
I don't know how many rc's there were, but I know that there's more 
capability in GRUB2 now than the manual covers.

Before I start into the specifics of my discoveries and questions, I 
want to say that I have not found any, useful or not, descriptions of 
the grub modules.  Oh, I know that many are self-explanatory by their 
name, like chainload, but what does efiemu do?  Either I haven't 
researched enough or there's nothing.  If anyone knows a place where 
this information exists, I would love to hear about it.

Configuring GRUB2 for an efi install means varying from "the Book." 
Using This document <https://help.ubuntu.com/community/UEFIBooting> I 
learned about the option "--with-platform=" and the only thing that 
"./configure --help" indicated was

>  --with-platform=PLATFORM
>                           select the host platform [[guessed]]
and I didn't know whether or not this was something that I should know 
because I use Linux or whether it was something specific to the GRUB2 
build.  Anyway, the referenced article had this command for configuring 
GRUB2 for a 64-bit {,U}EFI build.

> export EFI_ARCH=x86_64
> ./configure --with-platform=efi --target=${EFI_ARCH} --program-prefix=""

Now, to backtrack a little, when I built GRUB2 during my LFS-7.4 build, 
I used the configure options just as stated in the book.  The message I 
got at the end of configuring included the statement "Platform: i386" 
and the installed directory in /usr/lib/grub was i386-pc.

I can't remember where I read this in my research, but something to the 
effect that if grub installed its files as "*-pc" then it would have led 
to a GRUB2 situation of writing to the MSDOS MBR of a non-GPT disk or 
the MBR Protected Layer of a GPT disk.  I didn't want that.

So, I did a "DESTDIR" install of GRUB2, with the same configure options 
of the book with the addition of "--with-platform=efi"  Then the 
configure message said, "Platform: x86_64-efi" and "efiemu runtime: No 
(not available on efi."  And the directory in /usr/lib/grub was 
x86_64-efi.  I think this is significant to those who want to ultimately 
get grub on the EFI partition.

I found it also interesting that efiemu was not available.  Since I 
couldn't find any description of that module, I have concluded that it 
does something when grub is read from the MBR Protected Layer of a GPT 
disk.  I really don't know, though.

Now it comes to actually installing the grub files somewhere.  I know 
that "grub-install" utilizes "grub-mkimage" and "grub-setup" to 
accomplish its task.  I know what grub-mkimage does, but I don't know 
exactly what "grub-setup" does.  Does it just look at a disk to see 
what's there?  Or does it look to see what device a particular path 
refers to?

I can try to use grub-install for all of this or I can do it manually as 
in the article.  This is the point at which the options for grub-install 
become important.  And this statement from "grub-install --help" has me 
concerned.
> grub-install copies GRUB images into /boot/grub, and uses grub-setup
> to install grub into the boot sector.

I don't want to install grub to the boot sector because there is none on 
my disk.  Just the EFI partition.  And I just discovered that grub-setup 
doesn't exist on my LFS build now.  I'm wondering if that didn't happen 
because of the configure option --with-platform=efi.  Based on this 
info, I'm thinking of using

$ grub-install --bootloader-id=GRUB2-LFS-7.4 --efi-directory=$<my EFI 
partition mount point>

The manual install involves this command:

> 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

Obviously the author didn't install the compiled grub binaries so I 
would be working as root in some directory and using those binaries.  
${EFI_ARCH} for me is x86_64.  What I don't know is why those particular 
modules and should there be any more or any less. Anybody?

This is much, much longer than I intended it to be, but I think the 
detail was necessary so others can understand my questions, what I'm 
trying to do and how I'm trying to accomplish my goal.

Thanks,
Dan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20131107/8b321c41/attachment.html>


More information about the lfs-support mailing list