9.34. GRUB-2.12 for EFI

9.34.1. Introduction to GRUB

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.

Approximate build time: 1.0 SBU
Required disk space: 176 MB (with optional dependencies and download)
SHA256 Sum: 8240c381398a21f4eef993d16f0976d6a627e61054f0add275d195408f24efa9
Download Size: 1328 KB

GRUB Dependencies

Recommended

Optional

Section 9.31, “FreeType-2.14.2”, Section 9.30, “Fuse-3.18.1”, and Section 9.29, “LVM2-2.03.38”

If you are building GRUB for a 32-bit LFS system to boot it on a 64-bit UEFI firmware, rebuild "gcc" with the --enable-targets=all switch appended to the ../configure command.

9.34.2. Installation of GRUB

First, install font data if you've downloaded it and you've installed the optional dependency "freetype2":

mkdir -pv /usr/share/fonts/unifont &&
zcat ../unifont-17.0.01.pcf.gz > /usr/share/fonts/unifont/unifont.pcf
[Warning]

Warning

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.

Build GRUB with the following commands:

./configure --prefix=/usr        \
            --sysconfdir=/etc    \
            --disable-efiemu     \
            --with-platform=efi  \
            --target=aarch64     \
            --disable-werror
make

This package does not have a test suite providing meaningful results.

Now, if you've skipped the Chaper 8 GRUB package, install GRUB and skip the remaining instructions in this section:

make install
mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions

If you did NOT skip Section 10.4, “Using GRUB to Set Up the Boot Process” GRUB package, only install the components not installed from the Chapter 8 GRUB package instead:

make -C grub-core install

If you've installed the optional font data and Section 9.31, “FreeType-2.14.2”, install the grub-mkfont program and the font data files (without the font data files GRUB can still function normally, but the boot menu will be displayed using a coarse font or in a smaller region on the screen).

install -vm755 grub-mkfont /usr/bin/
install -vm644 ascii.h widthspec.h *.pf2 /usr/share/grub/

If both Section 9.30, “Fuse-3.18.1” and Section 9.29, “LVM2-2.03.38” are installed, also install the grub-mount program:

install -vm755 grub-mount /usr/bin/

9.34.3. Command Explanations

--with-platform=efi: Ensures building GRUB with EFI enabled.

--target=aarch64: Ensures building GRUB for arm64 even if building on a 32-bit LFS system. Most EFI firmware on arm64 does not support 32-bit bootloaders.

9.34.4. Configuring GRUB

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.

9.34.5. Contents

A list of the installed files, along with their short descriptions can be found at Section 10.4, “Using GRUB to Set Up the Boot Process”.

Listed below are the newly installed programs along with short descriptions.

Installed Programs: grub-mkfont and grub-mount (optional)
Installed Directories: /usr/lib/grub/arm64-efi

Short Descriptions

grub-mkfont

converts common font file formats into PF2

grub-mount

is a debug tool for filesystem driver