GRUB-2.14 for EFI

#### Beyond Linux® From Scratch (systemd Edition) - Version 13.0

### Chapter 5. File Systems and Disk Management

- Prev

  efibootmgr-18

- Next

  Using GRUB to Set Up the Boot Process with UEFI

- Up
- Home

# GRUB-2.14 for EFI

## 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.

### Note

This package is known to build and work properly using an LFS 13.0 platform.

### Package Information

- Download (HTTP): https://ftpmirror.gnu.org/grub/grub-2.14.tar.xz

- Download MD5 sum: 383f9effad01c235d2535357ff717543

- Download size: 7.4 MB

- Estimated disk space required: 176 MB (with optional dependencies and download)

- Estimated build time: 1.0 SBU

### Additional Downloads

Optional Unicode font data for the GRUB menu (only useful if FreeType is installed)

- Download (HTTP): https://unifoundry.com/pub/unifont/unifont-17.0.03/font-builds/unifont-17.0.03.pcf.gz

- Download MD5 sum: b926294d5bd663027223e424a7f557e3

- Download size: 1.3 MB

### GRUB Dependencies

#### Recommended

efibootmgr-18 (runtime)

#### Optional

FreeType-2.14.1, Fuse-3.18.1, and 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-15.2.0 with the `--enable-targets=all` switch appended to the ../configure command.

## Installation of GRUB

First, install font data as the `root` user if you've downloaded it and you've installed the optional dependency FreeType-2.14.1:

    mkdir -pv /usr/share/fonts/unifont &&
    zcat ../unifont-17.0.03.pcf.gz > /usr/share/fonts/unifont/unifont.pcf

### 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=x86_64      \
                --disable-werror     &&
    make

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

Now, if you've skipped the LFS GRUB package, as the `root` user 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've not skipped LFS GRUB package, as the `root` user, only install the components not installed from the LFS GRUB package instead:

    make -C grub-core install

If you've installed the optional font data and FreeType-2.14.1, 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 Fuse-3.18.1 and LVM2-2.03.38 are installed, also install the grub-mount program:

    install -vm755 grub-mount /usr/bin/

## Command Explanations

`--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.

## 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.

## Contents

A list of the installed files, along with their short descriptions can be found at ../../../../lfs/view/13.0-systemd/chapter08/grub.html#contents-gRUB.

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

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

### Short Descriptions

grub-mkfont | converts common font file formats into PF2
grub-mount | is a debug tool for filesystem driver

- Prev

  efibootmgr-18

- Next

  Using GRUB to Set Up the Boot Process with UEFI

- Up
- Home