diff --git a/chapter10/grub.xml b/chapter10/grub.xml index 233902633..8550c2bc9 100644 --- a/chapter10/grub.xml +++ b/chapter10/grub.xml @@ -18,11 +18,20 @@ - If your system has UEFI support and you wish to boot LFS with UEFI, - you should skip this page, and config GRUB with UEFI support + This section assume your system has UEFI support and you wish to boot + LFS with UEFI and GRUB built following the instructions in Chapter 8. + + + If you've installed GRUB for UEFI with optional dependencies following + BLFS, you should skip this page, and config GRUB with UEFI support using the instructions provided in the BLFS page. + + If your system does not support UEFI or you don't want to use it, + you'll need to figure out how to configure the booting process of + the system on your own. + @@ -34,18 +43,23 @@ just want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or LILO. - Ensure that an emergency boot disk is ready to rescue + Ensure that an emergency boot disk is ready to rescue the computer if the computer becomes unusable (un-bootable). If you do not - already have a boot device, you can create one. In order for the procedure - below to work, you need to jump ahead to BLFS and install - xorriso from the - libisoburn package. + already have a boot device, you can create one. To create a emergency + boot device for UEFI, consult section Create an Emergency Boot + Disk in + the BLFS page. -cd /tmp -grub-mkrescue --output=grub-img.iso -xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso + + + Turn off Secure Boot + + LFS does not have the essential packages to support Secure Boot. + To set up the boot process following the instructions in this section, + Secure Boot must be turned off from the configuration interface of the + firmware. Read the documentation provided by the manufacturer of your + system to find out how. @@ -71,10 +85,30 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso Setting Up the Configuration - GRUB works by writing data to the first physical track of the - hard disk. This area is not part of any file system. The programs - there access GRUB modules in the boot partition. The default location - is /boot/grub/. + GRUB works by creating an EFI executable in the EFI System + Partition (ESP). You can find the ESP with: + +fdisk -l | grep 'EFI System' + + If no ESP exists on your hard drive (for example, you are building + LFS on a fresh new system with a Live CD as the host distro), read + the BLFS page + for the instruction to create an ESP on your hard drive. + + If the ESP is not mounted at + /boot/efi (in the chroot), + mount it now: + +mount /boot/efi + + + The path to the device node is intentionally omitted in the + command. We expect the entry for mounting the ESP to + /boot/efi is already in + /etc/fstab. Add the entry before running the + command if you forgot to create an entry for the ESP in + . + The location of the boot partition is a choice of the user that affects the configuration. One recommendation is to have a separate small @@ -98,23 +132,50 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.isosda2. Install the GRUB files into /boot/grub and set up the boot track: + class="directory">/boot/grub and the GRUB EFI executable into + /boot/efi/EFI/BOOTAA64.EFI: - The following command will overwrite the current boot loader. Do not - run the command if this is not desired, for example, if using a third party - boot manager to manage the Master Boot Record (MBR). + The following command will overwrite + BOOTAA64.EFI. Do not run the command if this is + not desired, for example, if it contains a third party boot manager. + You can backup it with cp as it's a regular + file. -grub-install /dev/sda +grub-install --removable - If the system has been booted using UEFI, - grub-install will try to install files for the - x86_64-efi target, but those files - have not been installed in . - If this is the case, add to the - command above. + + --removable may seem strange here. The UEFI + firmware searches EFI executables for boot loaders in a hardcoded + path, EFI/BOOTAA64.EFI in the ESP, and other + boot loader paths listed in the EFI variables. We've not installed + the utilities for manipulating EFI variables so we need to install + the EFI executable into the hardcoded path. The hardcoded path is + usually used by removable devices (for example, USB thumb devices) + so the grub-install option for this purpose is + named --removable. + + + UEFI implementation usually prefers the boot loaders with paths + recorded in an EFI variable, to the boot loader with the hardcoded + search path. You may need to invoke the boot device selection menu + or setting interface of your EFI firmware on next boot to explicitly + select the bootloader. + + + Some UEFI implementation may completely skip the hardcoded path if + there are other boot loaders in the same hard drive with paths + recorded in an EFI variable. Then you need to create an EFI + variable for the newly installed boot loader. Install + efibootmgr, + then run the following commands: +mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars +efibootmgr -c -L LFS -l \EFI\BOOT\BOOTAA64.EFI -d /dev/sda + Replace /dev/sda with the device node of the + hard drive where you are installing GRUB into. +