aboutsummaryrefslogtreecommitdiffstats
path: root/chapter10/grub.xml
diff options
context:
space:
mode:
Diffstat (limited to 'chapter10/grub.xml')
-rw-r--r--chapter10/grub.xml128
1 files changed, 100 insertions, 28 deletions
diff --git a/chapter10/grub.xml b/chapter10/grub.xml
index 1b2335623..48db73bb0 100644
--- a/chapter10/grub.xml
+++ b/chapter10/grub.xml
@@ -18,12 +18,23 @@
<note>
<para>
- If your system has UEFI support and you wish to boot LFS with UEFI,
- you should skip the instructions in this page but still learn the
+ 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.
+ </para>
+ <para>
+ If you've installed GRUB for UEFI with optional dependencies following
+ BLFS, you should skip the instructions in this page but still learn the
syntax of <filename>grub.cfg</filename> and the method to specify
a partition in the file from this page, and configure GRUB with UEFI
- support using the instructions provided in
- <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>.
+ using the instructions provided in
+ <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>,
+ but replace <parameter>--target=x86_64-efi</parameter> with
+ <parameter>--target=arm64-efi</parameter> for the ARM64 system.
+ </para>
+ <para>
+ 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.
</para>
</note>
@@ -36,18 +47,23 @@
just want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or
LILO.</para></warning>
- <para> Ensure that an emergency boot disk is ready to <quote>rescue</quote>
+ <para>Ensure that an emergency boot disk is ready to <quote>rescue</quote>
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
- <userinput>xorriso</userinput> from the <ulink
- url="&blfs-book;multimedia/libisoburn.html">
- libisoburn</ulink> package.</para>
+ already have a boot device, you can create one. To create a emergency
+ boot device for UEFI, consult section <quote>Create an Emergency Boot
+ Disk</quote> in
+ <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>.</para>
-<screen role="nodump"><userinput>cd /tmp
-grub-mkrescue --output=grub-img.iso
-xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></screen>
+ </sect2>
+
+ <sect2>
+ <title>Turn off Secure Boot</title>
+ <para>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.</para>
</sect2>
<sect2>
@@ -73,10 +89,31 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
<sect2>
<title>Setting Up the Configuration</title>
- <para>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/.</para>
+ <para>GRUB works by creating an EFI executable in the EFI System
+ Partition (ESP). You can find the ESP with:</para>
+
+<screen role="nodump"><userinput>fdisk -l | grep 'EFI System'</userinput></screen>
+
+ <para>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
+ <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>
+ for the instruction to create an ESP on your hard drive.</para>
+
+ <para>If the ESP is not mounted at
+ <filename class="directory">/boot/efi</filename> (in the chroot),
+ mount it now:</para>
+
+<screen role="nodump"><userinput>mkdir -pv /boot/efi
+mount /boot/efi</userinput></screen>
+
+ <note>
+ <para>The path to the device node is intentionally omitted in the
+ command. We expect the entry for mounting the ESP to
+ <filename class="directory">/boot/efi</filename> is already in
+ <filename>/etc/fstab</filename>. Add the entry before running the
+ command if you forgot to create an entry for the ESP in
+ <xref linkend="ch-bootable-fstab"/>.</para>
+ </note>
<para>The location of the boot partition is a choice of the user that
affects the configuration. One recommendation is to have a separate small
@@ -101,23 +138,56 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
class="partition">sda2</filename>.</para>
<para>Install the GRUB files into <filename
- class="directory">/boot/grub</filename> and set up the boot track:</para>
+ class="directory">/boot/grub</filename> and the GRUB EFI executable into
+ <filename class="directory">/boot/efi/EFI/BOOT/BOOTAA64.EFI</filename>:</para>
<warning>
- <para>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).</para>
+ <para>The following command will overwrite
+ <filename>BOOTAA64.EFI</filename>. 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 <command>cp</command> as it's a regular
+ file.</para>
</warning>
-<screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen>
+<screen role="nodump"><userinput>grub-install --removable</userinput></screen>
<note>
- <para>If the system has been booted using UEFI,
- <command>grub-install</command> will try to install files for the
- <emphasis>x86_64-efi</emphasis> target, but those files
- have not been installed in <xref linkend="chapter-building-system"/>.
- If this is the case, add <option>--target i386-pc</option> to the
- command above.</para>
+ <para>
+ <parameter>--removable</parameter> may seem strange here. The UEFI
+ firmware searches EFI executables for boot loaders in a hardcoded
+ path, <filename>EFI/BOOT/BOOTAA64.EFI</filename> 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 <command>grub-install</command> option for this purpose is
+ named <parameter>--removable</parameter>.
+ </para>
+ <para>
+ 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.
+ </para>
+ <para>
+ 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
+ <ulink url="&blfs-book;postlfs/efibootmgr.html">efibootmgr</ulink>,
+ then run the following commands:
+
+<screen role="nodump"><userinput>mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars
+efibootmgr -B -L LFS || true
+efibootmgr -c -L LFS -l '\EFI\BOOT\BOOTAA64.EFI' -d /dev/sda
+umount /sys/firmware/efi/efivars</userinput></screen>
+
+ Replace <filename>/dev/sda</filename> with the device node of the
+ hard drive where you are installing GRUB into. For some UEFI
+ firmwares, <option>-e 3</option> option may be needed for the
+ <command>efibootmgr -c</command> command.
+ </para>
</note>
<!-- This does not seem to be true any more
@@ -147,6 +217,8 @@ insmod part_gpt
insmod ext2
set root=(hd0,2)
+insmod all_video
+
menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" {
linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro
}</literal>