Contents
See the page for GRUB in LFS book.
The GRUB package provides GRand Unified Bootloader. In this page it will be built with UEFI support, which is not enabled for GRUB built in LFS.
This package is known to build and work properly using an LFS 12.0 platform.
Download (HTTP): https://ftp.gnu.org/gnu/grub/grub-2.06.tar.xz
Download MD5 sum: cf0fd928b1e5479c8108ee52cb114363
Download size: 6.3 MB
Estimated disk space required: 183 MB
Estimated build time: 0.4 SBU (on 64-bit LFS, using parallelism=4)
Unicode font data used to display GRUB menu
Download (HTTP): https://unifoundry.com/pub/unifont/unifont-15.0.06/font-builds/unifont-15.0.06.pcf.gz
Download MD5 sum: 94ff8cb4d5674cd2f38b00cede5e06d5
Download size: 1.4 MB
GCC (only needed if building on 32-bit LFS)
Refer to GCC-13.2.0 page for download info.
efibootmgr-18 (runtime) and FreeType-2.13.1
First, install font data as the root
user:
mkdir -pv /usr/share/fonts/unifont && gunzip -c ../unifont-15.0.06.pcf.gz > /usr/share/fonts/unifont/unifont.pcf
Unset any environment variables which may affect the build:
unset {C,CPP,CXX,LD}FLAGS
Don't try “tuning” this package with custom compilation flags: this package is a bootloader, with low-level operations in the source code which is likely to be broken by some aggressive optimizations.
Fix an issue causing grub-install to fail when the
/boot
partition (or the root
partition if /boot
is not a separate
partition) is created by e2fsprogs-1.47.0 or later:
patch -Np1 -i ../grub-2.06-upstream_fixes-1.patch
If you are running a 32-bit LFS, prepare a 64-bit compiler:
case $(uname -m) in i?86 )
tar xf ../gcc-13.2.0.tar.xz
mkdir gcc-13.2.0/build
pushd gcc-13.2.0/build
../configure --prefix=$PWD/../../x86_64-gcc \
--target=x86_64-linux-gnu \
--with-system-zlib \
--enable-languages=c,c++ \
--with-ld=/usr/bin/ld
make all-gcc
make install-gcc
popd
export TARGET_CC=$PWD/x86_64-gcc/bin/x86_64-linux-gnu-gcc
esac
Build GRUB with the following commands:
./configure --prefix=/usr \ --sysconfdir=/etc \ --disable-efiemu \ --enable-grub-mkfont \ --with-platform=efi \ --target=x86_64 \ --disable-werror && unset TARGET_CC && make
This package does not have a test suite providing meaningful results.
Now, as the root
user:
make install && mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions
--enable-grub-mkfont
: Build
the tool named grub-mkfont to generate the font
file for the boot loader from the font data we've installed.
If the recommended dependency FreeType-2.13.1 is not installed, it is possible to omit this option and build GRUB. However, if grub-mkfont is not built, or the unicode font data is not available at the time GRUB is built, GRUB won't install any font for the boot loader. The GRUB boot menu will be displayed using a coarse font or in a smaller region on the screen.
--with-platform=efi
:
Ensures building GRUB with EFI enabled.
--target=x86_64
: Ensures
building GRUB for x86_64 even if building on a 32-bit LFS system.
Most EFI firmware on x86_64 does not support 32-bit bootloaders.
--target=i386
: A few 32-bit x86
platforms have EFI support. And, some x86_64 platforms have a
32-bit EFI implementation, but they are very old and rare. Use this
instead of --target=x86_64
if you are absolutely
sure that LFS is running on such a system.
Using GRUB to make the LFS system bootable on UEFI platform will be discussed in Using GRUB to Set Up the Boot Process with UEFI.
See the page for GRUB in LFS book.