Index: general/genlib/popt.xml
===================================================================
--- general/genlib/popt.xml (revision 2c5bbb89db327399e1ef0ff421371f2b678afadb)
+++ general/genlib/popt.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -104,5 +104,7 @@
-make install
+make install &&
+mv /usr/lib/libpopt.so.* /lib &&
+ln -sfv ../../lib/$(readlink /usr/lib/libpopt.so) /usr/lib/libpopt.so
@@ -123,4 +125,12 @@
+
+
+ mv /usr/lib/libpopt.so.* /lib and
+ ln -sfv ...: Moves the popt library on the root
+ filesystem, so it is avaliable in case
+ /usr is offline and
+ is installed and linked to popt.
+
Index: introduction/welcome/changelog.xml
===================================================================
--- introduction/welcome/changelog.xml (revision 2c5bbb89db327399e1ef0ff421371f2b678afadb)
+++ introduction/welcome/changelog.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -46,4 +46,9 @@
+ [xry111] - Add packages and instructions for booting on UEFI
+ based system.
+ Fixes #5379.
+
+
[ken] - Update to firefox-78.9.0 and JS-78.9.0 (security fixes).
Fixes #14804.
Index: packages.ent
===================================================================
--- packages.ent (revision 2c5bbb89db327399e1ef0ff421371f2b678afadb)
+++ packages.ent (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -323,4 +323,10 @@
+
+
+
+
+
+
Index: postlfs/filesystems/filesystems.xml
===================================================================
--- postlfs/filesystems/filesystems.xml (revision 2c5bbb89db327399e1ef0ff421371f2b678afadb)
+++ postlfs/filesystems/filesystems.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -42,4 +42,9 @@
+
+
+
+
+
Index: postlfs/filesystems/uefi-bootloaders/dummy.xml
===================================================================
--- postlfs/filesystems/uefi-bootloaders/dummy.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
+++ postlfs/filesystems/uefi-bootloaders/dummy.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ $LastChangedBy: renodr $
+ $Date: 2020-10-06 04:28:57 +0800 (二, 2020-10-06) $
+
+
+ Packages for UEFI Boot
+
+
+
Index: postlfs/filesystems/uefi-bootloaders/efibootmgr.xml
===================================================================
--- postlfs/filesystems/uefi-bootloaders/efibootmgr.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
+++ postlfs/filesystems/uefi-bootloaders/efibootmgr.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -0,0 +1,186 @@
+
+
+ %general-entities;
+
+
+
+
+
+
+
+]>
+
+
+
+
+
+ $LastChangedBy: bdubbs $
+ $Date: 2021-02-21 03:35:58 +0800 (日, 2021-02-21) $
+
+
+ efibootmgr-&efibootmgr-version;
+
+
+ efibootmgr
+
+
+
+ Introduction to efibootmgr
+
+
+ The efibootmgr package provides tools and
+ libraries to manipulate EFI variables.
+
+
+ &lfs101_checked;
+
+ Package Information
+
+
+
+ Download (HTTP):
+
+
+
+
+ Download (FTP):
+
+
+
+
+ Download MD5 sum: &efibootmgr-md5sum;
+
+
+
+
+ Download size: &efibootmgr-size;
+
+
+
+
+ Estimated disk space required: &efibootmgr-buildsize;
+
+
+
+
+ Estimated build time: &efibootmgr-time;
+
+
+
+
+ efibootmgr Dependencies
+
+ Required
+
+ and
+
+
+
+ User Notes:
+
+
+
+
+
+ Installation of efibootmgr
+
+
+ At first, fix an outdated hotfix declaration causing compilation
+ failure:
+
+
+sed -e '/extern int efi_set_verbose/d' -i src/efibootmgr.c
+
+
+ Build efibootmgr with the following
+ commands:
+
+
+make EFIDIR=LFS EFI_LOADER=grubx64.efi
+
+
+ This package does not have a test suite.
+
+
+
+ Now, as the root user:
+
+
+make install sbindir=/sbin EFIDIR=LFS
+
+
+
+
+ Command Explanations
+
+
+ EFIDIR=LFS:
+ This option specify the distro's subdirectory name under
+ /boot/efi/EFI.
+ The building system of this package needs it to be set explicitly.
+
+
+
+ EFI_LOADER=grubx64.efi:
+ This option specify the name of the default EFI boot loader. It is
+ set to match the EFI boot loader provided by
+ GRUB.
+
+
+
+ sbindir=/sbin:
+ Make efibootmgr avaliable even if
+ /usr is offline.
+
+
+
+
+ Contents
+
+
+ Installed Programs
+
+
+
+ efibootdump and efibootmgr
+
+
+
+
+
+ Short Descriptions
+
+
+
+
+ efibootmgr
+
+
+ is a tool to display individual UEFI boot options, from a file
+ or an UEFI variable
+
+
+ efibootdump
+
+
+
+
+
+ efibootmgr
+
+
+ is a tool to manipulate the UEFI Boot Manager
+
+
+ efibootmgr
+
+
+
+
+
+
+
+
+
Index: postlfs/filesystems/uefi-bootloaders/efivar.xml
===================================================================
--- postlfs/filesystems/uefi-bootloaders/efivar.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
+++ postlfs/filesystems/uefi-bootloaders/efivar.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -0,0 +1,218 @@
+
+
+ %general-entities;
+
+
+
+
+
+
+
+]>
+
+
+
+
+
+ $LastChangedBy: bdubbs $
+ $Date: 2021-02-21 03:35:58 +0800 (日, 2021-02-21) $
+
+
+ efivar-&efivar-version;
+
+
+ efivar
+
+
+
+ Introduction to efivar
+
+
+ The efivar package provides tools and
+ libraries to manipulate EFI variables.
+
+
+ &lfs101_checked;
+
+ Package Information
+
+
+
+ Download (HTTP):
+
+
+
+
+ Download (FTP):
+
+
+
+
+ Download MD5 sum: &efivar-md5sum;
+
+
+
+
+ Download size: &efivar-size;
+
+
+
+
+ Estimated disk space required: &efivar-buildsize;
+
+
+
+
+ Estimated build time: &efivar-time;
+
+
+
+
+ Additional Downloads
+
+
+
+ Required patch:
+
+
+
+
+
+ User Notes:
+
+
+
+
+
+ Installation of efivar
+
+
+ At first, apply a patch to fix an issue breaking the build with GCC 9
+ or later:
+
+
+patch -Np1 -i ../efivar-37-gcc_9-1.patch
+
+
+ Build efivar with the following
+ commands:
+
+
+make CFLAGS="-O2 -Wno-stringop-truncation"
+
+
+ The test suite of this package is dangerous. Running it may trigger
+ firmware bugs and make your system unusable without using some special
+ hardware to reprogram the firmware.
+
+
+
+ Now, as the root user:
+
+
+make install LIBDIR=/usr/lib BINDIR=/bin
+
+
+ Move the shared libraries to /lib,
+ and recreate the symlinks in /usr/lib:
+
+
+mv /usr/lib/libefi{boot,var}.so.* /lib &&
+ln -sfv ../../lib/$(readlink /usr/lib/libefiboot.so) /usr/lib/libefiboot.so &&
+ln -sfv ../../lib/$(readlink /usr/lib/libefivar.so) /usr/lib/libefivar.so
+
+
+
+
+
+ Command Explanations
+
+
+ CFLAGS="-O2 -Wno-stringop-truncation":
+ This option overrides the compiler flags defaulted by this package,
+ to avoid build failure.
+
+
+
+ LIBDIR=/usr/lib:
+ This option overrides the default library directory of the package
+ (/usr/lib64, which is not used
+ by LFS.)
+
+
+
+ BINDIR=/bin:
+ Make efivar avaliable even if
+ /usr is offline.
+
+
+
+
+ Contents
+
+
+ Installed Programs
+ Installed Libraries
+ Installed Directories
+
+
+
+ efivar
+
+
+ libefiboot.so and libefivar.so
+
+
+ /usr/include/efivar
+
+
+
+
+
+ Short Descriptions
+
+
+
+
+ efivar
+
+
+ is a tool to manipulate UEFI variables
+
+
+ efivar
+
+
+
+
+
+ libefiboot.so
+
+
+ is a library used by efibootmgr
+
+
+ libefiboot.so
+
+
+
+
+
+ libefivar.so
+
+
+ is a library for the manipulation of EFI variables
+
+
+ libefiboot.so
+
+
+
+
+
+
+
+
+
Index: postlfs/filesystems/uefi-bootloaders/grub-efi.xml
===================================================================
--- postlfs/filesystems/uefi-bootloaders/grub-efi.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
+++ postlfs/filesystems/uefi-bootloaders/grub-efi.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -0,0 +1,214 @@
+
+
+ %general-entities;
+
+
+
+
+
+
+
+
+
+
+
+]>
+
+
+
+
+
+ $LastChangedBy: bdubbs $
+ $Date: 2021-02-21 03:35:58 +0800 (日, 2021-02-21) $
+
+
+ GRUB-&grub-version; for EFI
+
+
+ grub-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.
+
+
+ &lfs101_checked;
+
+ Package Information
+
+
+
+ Download (HTTP):
+
+
+
+
+ Download (FTP):
+
+
+
+
+ Download MD5 sum: &grub-efi-md5sum;
+
+
+
+
+ Download size: &grub-efi-size;
+
+
+
+
+ Estimated disk space required: &grub-efi-buildsize;
+
+
+
+
+ Estimated build time: &grub-efi-time;
+
+
+
+
+ Additional Downloads
+
+
+ Unicode font data used to display GRUB menu
+
+
+ Download (HTTP):
+
+
+
+
+ Download MD5 sum: &unifont-md5sum;
+
+
+
+
+ Download size: &unifont-size;
+
+
+
+
+ GRUB Dependencies
+
+ Required (runtime)
+
+
+
+
+ Recommended
+
+
+
+
+ Optional
+
+
+
+
+ User Notes:
+
+
+
+
+
+ Installation of GRUB
+
+
+ At first, install font data as the
+ root user:
+
+
+mkdir -pv /usr/share/fonts/unifont &&
+gunzip -c unifont-&unifont-version;.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.
+
+
+
+ Build GRUB with the following commands:
+
+
+./configure --prefix=/usr \
+ --sbindir=/sbin \
+ --sysconfdir=/etc \
+ --disable-efiemu \
+ --enable-grub-mkfont \
+ --with-platform=efi \
+ --disable-werror &&
+
+make
+
+
+ This package does not have a test suite providing meaningful result.
+
+
+
+ Now, as the root user:
+
+
+make install &&
+mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions
+
+
+
+
+ Command Explanations
+
+
+ --enable-grub-mkfont: Built the tool named
+ grub-mkfont to generate font file for the boot
+ loader, from the font data we've installed.
+
+
+
+ If the recommended dependency is not
+ installed, it's possible to omit this option and build GRUB. However,
+ if grub-mkfont is not built, or the unicode font
+ data is not avaliable at the time GRUB is built, GRUB won't install
+ any font for the boot loader. The GRUB boot menu will be displayed
+ in an ugly way, and the early stage of kernel initialization will be
+ in blind mode
- you can't see any kernel message before
+ the graphics card driver is initialized. It will be very difficult to
+ diagnostic some boot issue (especially, if the graphics driver is
+ built as module).
+
+
+
+ --with-platform=efi: Ensures to build GRUB with
+ for EFI.
+
+
+
+
+
+ Configuring GRUB
+
+
+ Using GRUB to make the LFS system bootable on UEFI platform will be
+ discussed in .
+
+
+
+
+ Contents
+
+ See the page for GRUB in LFS book.
+
+
+
Index: postlfs/filesystems/uefi-bootloaders/grub-setup.xml
===================================================================
--- postlfs/filesystems/uefi-bootloaders/grub-setup.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
+++ postlfs/filesystems/uefi-bootloaders/grub-setup.xml (revision 756a787f17843fefeb3044393a4c868e39f230c7)
@@ -0,0 +1,429 @@
+
+
+ %general-entities;
+]>
+
+
+
+
+
+ $LastChangedBy: bdubbs $
+ $Date: 2021-02-21 03:35:58 +0800 (日, 2021-02-21) $
+
+
+ Using GRUB to Set Up the Boot Process with UEFI
+
+
+ Turn Off Secure Boot
+
+
+ BLFS doesn't have the essential packages to support Secure Boot. To
+ set up the boot process with GRUB for UEFI installed in BLFS, 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.
+
+
+
+
+ Create an Emergency Boot Disk
+
+
+ Ensure that an emergency boot disk is ready to rescue
+ the system, in case the system becomes un-bootable. To make a
+ emergency boot disk with GRUB for EFI platform, at first find a spare
+ USB flash drive and create a
+ vfat file system on it.
+ Install first, then
+ as the root user:
+
+
+
+
+ The following command will erase all directories and files in the
+ partition. Make sure your USB flash drive contains no data which
+ will be needed, and change sdx1 to the
+ device node corresponding to the first partition of the USB flash
+ drive. Be careful not to overwrite your hard drive with a typo!
+
+
+
+ mkfs.vfat /dev/sdx1
+
+
+ Still as the root user, use
+ the CLI of fdisk utility to set the first parition
+ of the USB flash drive to be an EFI system
partition
+ (change sdx to the device node corresponding
+ to your USB flash drive):
+
+
+fdisk /dev/sdx
+
+Welcome to fdisk (util-linux 2.36.2).
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): t
+Selected partition 1
+Hex code or alias (type L to list all): ef
+Changed type of partition 'Linux' to 'EFI (FAT-12/16/32)'.
+
+Command (m for help): w
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
+
+
+ Still as the root user,
+ create a mount point for the EFI partition on the USB flash drive
+ and mount it:
+
+
+mkdir -pv /mnt/rescue &&
+mount -v -t vfat /dev/sdx1 /mnt/rescue
+
+
+ Install GRUB for EFI on the partition:
+
+
+grub-install --removable --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue/grub
+
+
+ Unmount the partition:
+
+
+umount /mnt/rescue
+
+
+ Now the USB flash drive can be used as a emergency boot disk on x86-64
+ UEFI platform. It will boot the system and show GRUB shell. Then you
+ can type commands to boot your operation systems on the hard drive.
+ To get how to select the boot device, read the manual of your
+ motherboard or laptop.
+
+
+
+
+
+ Kernel Configuration for UEFI support
+
+
+ Enable the following options in the kernel configuration and recompile
+ the kernel if necessary:
+
+
+Processor type and features --->
+ [*] EFI runtime service support [CONFIG_EFI]
+ [*] EFI stub support [CONFIG_EFI_STUB]
+Firmware Drivers --->
+ EFI (Extensible Firmware Interface) Support --->
+ < > EFI Variable Support via sysfs [CONFIG_EFI_VARS]
+ [*] Export efi runtime maps to sysfs [CONFIG_EFI_RUNTIME_MAP]
+Enable the block layer --->
+ Partition Types --->
+ [*] Advanced partition selection [CONFIG_PARTITION_ADVANCED]
+ [*] EFI GUID Partition support [CONFIG_EFI_PARTITION]
+Device Drivers --->
+ Graphics support --->
+ Frame buffer Devices --->
+ Support for frame buffer devices ---> [CONFIG_FB]
+ [*] EFI-based Framebuffer support [CONFIG_FB_EFI]
+ Console display driver support --->
+ [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE]
+File systems --->
+ Pseudo filesystems --->
+ <*/M> EFI Variable filesystem [CONFIG_EFIVAR_FS]
+
+
+ The meaning of the configure options:
+
+
+ CONFIG_EFI_STUB
+
+ Though EFI stub is designed to boot a kernel directly from
+ the UEFI firmware (without bootloaders like GRUB), GRUB needs the
+ kernel being loaded to support EFI handover protocol enabled by
+ this option.
+
+
+
+
+ CONFIG_EFI_VARS
+
+ Don't use this option deprecated because of an 1024-byte
+ variable size limit. Its function is replaced by
+ CONFIG_EFIVAR_FS.
+
+
+
+
+ CONFIG_FB_EFI and CONFIG_FRAMEBUFFER_CONSOLE
+
+ The combination of these two options allows the kernel to
+ print debug messages (along with Tux logos) on early stage of boot
+ process with UEFI.
+
+
+
+
+
+
+
+
+ Find or Create the EFI System Partition
+
+
+ On EFI based system, the bootloaders are installed in a special FAT32
+ partition called EFI System Partition (ESP).
+ If your system supports EFI, and a recent version of Linux
+ distribution or Windows is pre-installed, it's likely that the ESP
+ is already created. As the
+ root user, list all the
+ partitions on your hard drive (replace sda
+ with the device node corresponding to the hard drive):
+
+
+ fdisk -l /dev/sda
+
+
+ The Type
column of the ESP should be
+ EFI System.
+
+
+
+ If the system or the hard drive is new, or it's the first time to
+ install an UEFI booted OS on the system, the ESP may be nonexistent.
+ Then create a new partition, make a
+ vfat file system on it,
+ and set the partition type to EFI system
. Read the
+ instructions for the emergency boot device above as a reference.
+
+
+
+
+ Some (old) UEFI implementations may demand the ESP to be the first
+ partition on the disk.
+
+
+
+
+ Now, as the root user,
+ create the mount point for the ESP, and mount it (replace
+ sda1 with the device node corresponding to
+ the ESP):
+
+
+mkdir -pv /boot/efi &&
+mount -v -t vfat /dev/sda1 /boot/efi
+
+
+ It's recommended to add an entry for the ESP in
+ /etc/fstab, so it will be mounted automatically
+ during system boot:
+
+
+cat >> /etc/fstab << EOF
+/dev/sda1 /boot/efi vfat defaults 0 1
+EOF
+
+
+
+
+ Mount the EFI Variable File System
+
+
+ The installation of GRUB on UEFI platform requires the EFI Variable
+ file system (efivarfs)
+ mounted. As the root user:
+
+
+mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars
+
+
+
+ If the system is booted with UEFI and systemd,
+ efivarfs will be mounted
+ automatically. However in LFS chroot environment it still needs to
+ be mounted manually.
+
+
+
+
+ It's recommended to add an entry for the
+ efivarfs in
+ /etc/fstab, so it will be mounted automatically
+ during system boot:
+
+
+cat >> /etc/fstab << EOF
+efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 1
+EOF
+
+
+
+ If the system is not booted with UEFI, the directory
+ /sys/firmware/efi will be
+ missing. In this case you should boot the system in UEFI mode with
+ the emergency boot disk created as above.
+
+
+
+
+
+ Setting Up the Configuration
+
+
+ On UEFI based systems, GRUB works by installing an EFI application
+ (a special kind of PE executable) into
+ /boot/efi/EFI/[id]/grubx64.efi,
+ where /boot/efi is the mount
+ point of the ESP, and [id] is replaced with an
+ identifier specified in the grub-install command
+ line. Then GRUB will create an entry in the EFI variables containing
+ the path EFI/[id]/grubx64.efi, so the EFI firmware
+ can find grubx64.efi and load it.
+
+
+
+ grubx64.efi is very lightweight (136 KB with
+ GRUB-2.06~rc1) so it won't cost much space in the ESP. A typical ESP
+ size is 100 MB (for Windows boot manager, which cost about 50 MB in
+ the ESP). Once grubx64.efi loaded by the
+ firmware, it will load GRUB modules in the boot partition.
+ The default location is
+ /boot/grub.
+
+
+
+ As the root user, install
+ the GRUB files into /boot/efi/EFI/LFS/grubx64.efi
+ and /boot/grub, and set up the
+ boot entry in the EFI variables:
+
+
+grub-install --bootloader-id=LFS --recheck
+
+
+ If the installation is successful, the output should be:
+
+
+Installing for x86_64-efi platform.
+Installation finished. No error reported.
+
+
+ Issue efibootmgr to recheck the EFI boot
+ configuration. An example of the output is:
+
+
+BootCurrent: 0000
+Timeout: 1 seconds
+BootOrder: 0005,0000,0002,0001,0003,0004
+Boot0000* ARCH
+Boot0001* UEFI:CD/DVD Drive
+Boot0002* Windows Boot Manager
+Boot0003* UEFI:Removable Device
+Boot0004* UEFI:Network Device
+Boot0005* LFS
+
+
+ Note that 0005 is the first in
+ BootOrder, and Boot0005
+ is LFS. So on the next boot, GRUB installed
+ by LFS will be used to boot the system.
+
+
+
+
+
+ Creating the GRUB Configuration File
+
+
+ /boot/grub/grub.cfg
+
+
+
+ Generate /boot/grub/grub.cfg to configure the
+ boot menu of GRUB:
+
+
+cat > /boot/grub/grub.cfg << EOF
+# Begin /boot/grub/grub.cfg
+set default=0
+set timeout=5
+
+insmod part_gpt
+insmod ext2
+set root=(hd0,2)
+
+if loadfont /boot/grub/fonts/unicode.pf2; then
+ set gfxmode=auto
+ insmod all_video
+ terminal_output gfxterm
+fi
+
+menuentry "GNU/Linux, Linux 5.10.17-lfs-10.1" {
+ linux /boot/vmlinuz-5.10.17-lfs-10.1 root=/dev/sda2 ro
+}
+
+menuentry "Firmware Setup" {
+ fwsetup
+}
+EOF
+
+
+ (hd0,2), sda2, and
+ 5.10.17-lfs-10.1 should be replaced to match your
+ configuration.
+
+
+
+
+ From GRUB's perspective, the files are relative to the partition
+ used. If you used a separate /boot partition, remove /boot from the
+ above paths (to kernel and to unicode.pf2). You
+ will also need to change the set root line to point to the boot
+ partition.
+
+
+
+
+ The Firmware Setup entry can be used to enter the
+ configuration interface provided by the firmware (sometimes called
+ "BIOS configuration").
+
+
+
+
+ Dual-booting with Windows
+
+
+ Add a menu entry for Windows into grub.cfg:
+
+
+cat >> /boot/grub/grub.cfg << EOF
+# Begin Windows addition
+
+menuentry "Windows 10" {
+ insmod fat
+ insmod chain
+ set root=(hd0,1)
+ chainloader /EFI/Microsoft/Boot/bootmgfw.efi
+}
+EOF
+
+
+ (hd0,1) should be replaced with the GRUB
+ designated name for the ESP. chainloader
+ directive can be used to tell GRUB to run another EFI executable,
+ in this case the Windows Boot Manager. You may put more usable tools
+ in EFI executable format (for example, an EFI shell) into the ESP and
+ create GRUB entries for them.
+
+
+
+
+