help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Noob trying to build for x86_64-efi on an x86_64 legacy-booting PC


From: Frantisek Rysanek
Subject: Noob trying to build for x86_64-efi on an x86_64 legacy-booting PC
Date: Thu, 07 Nov 2019 22:19:14 +0100

Dear everyone,

I'm trying to set up an UEFI netbooting environment in our LAN,
essentially to allow for diskless clients that don't support the 
"legacy BIOS PXE-boot" anymore.
I've been using the legacy PXE boot for ages, and I've already 
managed to configure my DHCP server to distinguish between legacy and 
UEFI PXEbooting clients, now I need some bootloader for the client 
machines. Historically I've been using PXElinux (and I'm still trying 
to get it to work in UEFI mode too - out of scope here)
but it seems to me that Grub2 also looks suitable for the job.

I've managed to download the grubx64.efi from Debian Buster 
netinstall and I've managed to get that started on a client,
but this debianese cut of UEFI Grub has a debianese grub.conf linked 
in, preventing me from supplying my own configuration...
it doesn't ask the TFTP server for a grub.cfg, just for some help 
texts and such.
Hence my attempts to compile my own cut of UEFI Grub.

On a server running Debian 9 booting in legacy mode, I've downloaded 
the source code of Grub 2.04 and obviously I ran the basic 
./configure and make.
As for options to ./configure, I used just --prefix=/usr .
And I followed the clues about dependencies in the README and in the 
output of ./configure.
And I found some existing howto's on how to use grub-mknetdir and 
grub-mkimage to create the main grub UEFI binary and the netbootable 
modules folder.

So my progress went like:

wget https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz
tar xvf grub-2.04.tar.xz
cd grub-2.04
./configure --prefix=/usr
cd grub-core
../grub-mknetdir -d . --net-directory=/tftpboot/grub/ --subdir=/

# ^^ this way I end up with the Grub modules installed in
# /tftpboot/grub/i386-pc/ . Sounds about right.
# Even though my system is really x86_64 and I need UEFI.

# My first attempt at grub-mkimage has failed with
#  "invalid ELF header" (after loading kernel.img, 
#  as witnessed by strace) :

../grub-mkimage -O x86_64-efi -d . -o grubx64.efi -p "" \
   part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal

# Then I found another example of the grub-mkimage command:

../grub-mkimage -C xz -O x86_64-efi \
   -o /tftpboot/grub/bootx64.efi -d . '--prefix=(tftp)/i386-pc/' \ 
   normal tftp efinet chain echo net gzio xzio linux efi_gop \
   efi_uga png gfxterm gfxterm_background gfxterm_menu \
   serial part_gpt part_msdos boot multiboot progress search \
   ext2 xfs reiserfs jfs hfsplus fat ntfs configfile test sleep \
   tr reboot halt

...this last mkimage complains that the "efinet" module does not 
exist. I can see the source .C file, but it did not get compiled into 
a binary module.

The "efinet" sounds like a crucial module to get the UEFI netboot to 
work... 
How do I tell the Grub makefiles to build this module for me?
Do I need to use the --with-platform= arg to ./configure ?
If yes, what platform should I specify?
If I do not specify this explicitly, ./configure auto-detects 
i386-pc. I'm puzzled if these platforms are the same list as the one 
suported by the -O argument to grub-mkimage, or of i386-pc "configure 
platform" is okay for a final x86_64-efi Grub image...

Many of the examples and advice in the interwebs effectively tell you 
to "make install" the Grub on the build system (server) after you 
build from source, and then use grub-mkimage (which will take the 
individual parts from the system-wide places). This is not my aim - I 
have some older hardware booting Debian 9 in "legacy BIOS mode", that 
I'm using as a "build machine", but I need to compile and prepare 
Grub for PXE-booting UEFI-only clients. I'm wondering if I should 
build and install Grub with some pretty wild "alternative" --prefix, 
so as not to clobber the stock bootloader on the build machine... or 
compile the Grub in a UEFI-capable VM? (courtesy of OVMF for 
instance)...

Still I guess it should be pretty simple to build the efinet module 
(and maybe other missing modules) for UEFI netbootable Grub,
on a machine that has never heard of UEFI.

Thanks for your polite attention, any ideas are welcome...

Frank Rysanek




reply via email to

[Prev in Thread] Current Thread [Next in Thread]