source: chapter10/grub.xml@ 53415749

xry111/arm64 xry111/arm64-12.0
Last change on this file since 53415749 was 53415749, checked in by Xi Ruoyao <xry111@…>, 13 months ago

arm64: Fix two typos in BOOTAA64.EFI path

  • Property mode set to 100644
File size: 12.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-bootable-grub" role="wrap">
9 <?dbhtml filename="grub.html"?>
10
11 <sect1info condition="script">
12 <productname>grub</productname>
13 <productnumber>&grub-version;</productnumber>
14 <address>&grub-url;</address>
15 </sect1info>
16
17 <title>Using GRUB to Set Up the Boot Process</title>
18
19 <note>
20 <para>
21 This section assume your system has UEFI support and you wish to boot
22 LFS with UEFI and GRUB built following the instructions in Chapter 8.
23 </para>
24 <para>
25 If you've installed GRUB for UEFI with optional dependencies following
26 BLFS, you should skip this page, and configure GRUB with UEFI support
27 using the instructions provided in
28 <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>,
29 but replace <parameter>--target=x86_64-efi</parameter> with
30 <parameter>--target=arm64-efi</parameter> for the ARM64 system.
31 </para>
32 <para>
33 If your system does not support UEFI or you don't want to use it,
34 you'll need to figure out how to configure the booting process of
35 the system on your own.
36 </para>
37 </note>
38
39 <sect2>
40 <title>Introduction</title>
41
42 <warning><para>Configuring GRUB incorrectly can render your system
43 inoperable without an alternate boot device such as a CD-ROM or bootable
44 USB drive. This section is not required to boot your LFS system. You may
45 just want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or
46 LILO.</para></warning>
47
48 <para>Ensure that an emergency boot disk is ready to <quote>rescue</quote>
49 the computer if the computer becomes unusable (un-bootable). If you do not
50 already have a boot device, you can create one. To create a emergency
51 boot device for UEFI, consult section <quote>Create an Emergency Boot
52 Disk</quote> in
53 <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>.</para>
54
55 </sect2>
56
57 <sect2>
58 <title>Turn off Secure Boot</title>
59
60 <para>LFS does not have the essential packages to support Secure Boot.
61 To set up the boot process following the instructions in this section,
62 Secure Boot must be turned off from the configuration interface of the
63 firmware. Read the documentation provided by the manufacturer of your
64 system to find out how.</para>
65 </sect2>
66
67 <sect2>
68 <title>GRUB Naming Conventions</title>
69
70 <para>GRUB uses its own naming structure for drives and partitions in
71 the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
72 is the hard drive number and <emphasis>m</emphasis> is the partition
73 number. The hard drive numbers start from zero, but the partition numbers
74 start from one for normal partitions (from five for extended partitions).
75 Note that this is different from earlier versions where
76 both numbers started from zero. For example, partition <filename
77 class="partition">sda1</filename> is <emphasis>(hd0,1)</emphasis> to
78 GRUB and <filename class="partition">sdb3</filename> is
79 <emphasis>(hd1,3)</emphasis>. In contrast to Linux, GRUB does not
80 consider CD-ROM drives to be hard drives. For example, if using a CD
81 on <filename class="partition">hdb</filename> and a second hard drive
82 on <filename class="partition">hdc</filename>, that second hard drive
83 would still be <emphasis>(hd1)</emphasis>.</para>
84
85 </sect2>
86
87 <sect2>
88 <title>Setting Up the Configuration</title>
89
90 <para>GRUB works by creating an EFI executable in the EFI System
91 Partition (ESP). You can find the ESP with:</para>
92
93<screen role="nodump"><userinput>fdisk -l | grep 'EFI System'</userinput></screen>
94
95 <para>If no ESP exists on your hard drive (for example, you are building
96 LFS on a fresh new system with a Live CD as the host distro), read
97 <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>
98 for the instruction to create an ESP on your hard drive.</para>
99
100 <para>If the ESP is not mounted at
101 <filename class="directory">/boot/efi</filename> (in the chroot),
102 mount it now:</para>
103
104<screen role="nodump"><userinput>mkdir -pv /boot/efi
105mount /boot/efi</userinput></screen>
106
107 <note>
108 <para>The path to the device node is intentionally omitted in the
109 command. We expect the entry for mounting the ESP to
110 <filename class="directory">/boot/efi</filename> is already in
111 <filename>/etc/fstab</filename>. Add the entry before running the
112 command if you forgot to create an entry for the ESP in
113 <xref linkend="ch-bootable-fstab"/>.</para>
114 </note>
115
116 <para>The location of the boot partition is a choice of the user that
117 affects the configuration. One recommendation is to have a separate small
118 (suggested size is 200 MB) partition just for boot information. That way
119 each build, whether LFS or some commercial distro, can access the same boot
120 files and access can be made from any booted system. If you choose to do
121 this, you will need to mount the separate partition, move all files in the
122 current <filename class="directory">/boot</filename> directory (e.g. the
123 Linux kernel you just built in the previous section) to the new partition.
124 You will then need to unmount the partition and remount it as <filename
125 class="directory">/boot</filename>. If you do this, be sure to update
126 <filename>/etc/fstab</filename>.</para>
127
128 <para>Leaving <filename class="directory">/boot</filename> on
129 the current LFS partition will also work, but configuration
130 for multiple systems is more difficult.</para>
131
132 <para>Using the above information, determine the appropriate
133 designator for the root partition (or boot partition, if a separate
134 one is used). For the following example, it is assumed that the root
135 (or separate boot) partition is <filename
136 class="partition">sda2</filename>.</para>
137
138 <para>Install the GRUB files into <filename
139 class="directory">/boot/grub</filename> and the GRUB EFI executable into
140 <filename class="directory">/boot/efi/EFI/BOOT/BOOTAA64.EFI</filename>:</para>
141
142 <warning>
143 <para>The following command will overwrite
144 <filename>BOOTAA64.EFI</filename>. Do not run the command if this is
145 not desired, for example, if it contains a third party boot manager.
146 You can backup it with <command>cp</command> as it's a regular
147 file.</para>
148 </warning>
149
150<screen role="nodump"><userinput>grub-install --removable</userinput></screen>
151
152 <note>
153 <para>
154 <parameter>--removable</parameter> may seem strange here. The UEFI
155 firmware searches EFI executables for boot loaders in a hardcoded
156 path, <filename>EFI/BOOT/BOOTAA64.EFI</filename> in the ESP, and other
157 boot loader paths listed in the EFI variables. We've not installed
158 the utilities for manipulating EFI variables so we need to install
159 the EFI executable into the hardcoded path. The hardcoded path is
160 usually used by removable devices (for example, USB thumb devices)
161 so the <command>grub-install</command> option for this purpose is
162 named <parameter>--removable</parameter>.
163 </para>
164 <para>
165 UEFI implementation usually prefers the boot loaders with paths
166 recorded in an EFI variable, to the boot loader with the hardcoded
167 search path. You may need to invoke the boot device selection menu
168 or setting interface of your EFI firmware on next boot to explicitly
169 select the bootloader.
170 </para>
171 <para>
172 Some UEFI implementation may completely skip the hardcoded path if
173 there are other boot loaders in the same hard drive with paths
174 recorded in an EFI variable. Then you need to create an EFI
175 variable for the newly installed boot loader. Install
176 <ulink url="&blfs-book;postlfs/efibootmgr.html">efibootmgr</ulink>,
177 then run the following commands:
178
179<screen role="nodump"><userinput>mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars
180efibootmgr -B -L LFS || true
181efibootmgr -c -L LFS -l '\EFI\BOOT\BOOTAA64.EFI' -d /dev/sda
182umount /sys/firmware/efi/efivars</userinput></screen>
183
184 Replace <filename>/dev/sda</filename> with the device node of the
185 hard drive where you are installing GRUB into. For some UEFI
186 firmwares, <option>-e 3</option> option may be needed for the
187 <command>efibootmgr -c</command> command.
188 </para>
189 </note>
190
191<!-- This does not seem to be true any more
192 <note><para><application>grub-install</application> is a script and calls another
193 program, grub-probe, that may fail with a message "cannot stat `/dev/root'".
194 If so, create a temporary symbolic link from your root partition to /dev/root:</para>
195
196<screen role="nodump"><userinput>ln -sv /dev/sda2 /dev/root</userinput></screen>
197
198 <para>The symbolic link will only be present until the system is rebooted.
199 The link is only needed for the installation procedure.
200 </para></note>
201-->
202 </sect2>
203
204 <sect2 id="grub-cfg">
205 <title>Creating the GRUB Configuration File</title>
206
207 <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para>
208
209 <screen><userinput>cat &gt; /boot/grub/grub.cfg &lt;&lt; "EOF"
210<literal># Begin /boot/grub/grub.cfg
211set default=0
212set timeout=5
213
214insmod ext2
215set root=(hd0,2)
216
217insmod all_video
218
219menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" {
220 linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro
221}</literal>
222EOF</userinput></screen>
223
224 <note><para>From <application>GRUB</application>'s perspective, the
225 kernel files are relative to the partition used. If you
226 used a separate /boot partition, remove /boot from the above
227 <emphasis>linux</emphasis> line. You will also need to change the
228 <emphasis>set root</emphasis> line to point to the boot partition.
229 </para></note>
230
231 <note>
232 <para>The GRUB designator for a partition may change if you added or
233 removed some disks (including removable disks like USB thumb devices).
234 The change may cause boot failure because
235 <filename>grub.cfg</filename> refers to some <quote>old</quote>
236 designators. If you wish to avoid such a problem, you may use
237 the UUID of a partition and the UUID of a filesystem instead of a GRUB designator to
238 specify a device.
239 Run <command>lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT</command> to show
240 the UUIDs of your filesystems (in the <literal>UUID</literal> column) and
241 partitions (in the <literal>PARTUUID</literal> column). Then replace
242 <literal>set root=(hdx,y)</literal> with
243 <literal>search --set=root --fs-uuid <replaceable>&lt;UUID of the filesystem
244 where the kernel is installed&gt;</replaceable></literal>, and replace
245 <literal>root=/dev/sda2</literal> with
246 <literal>root=PARTUUID=<replaceable>&lt;UUID of the partition where LFS
247 is built&gt;</replaceable></literal>.</para>
248 <para>Note that the UUID of a partition is completely different from the
249 UUID of the filesystem in this partition. Some online resources may
250 instruct you to use
251 <literal>root=UUID=<replaceable>&lt;filesystem UUID&gt;</replaceable></literal>
252 instead of
253 <literal>root=PARTUUID=<replaceable>&lt;partition UUID&gt;</replaceable></literal>,
254 but doing so will require an initramfs, which is beyond the scope of
255 LFS.</para>
256 <para>The name of the device node for a partition in
257 <filename class='directory'>/dev</filename> may also change (this is less
258 likely than a GRUB designator change). You can also replace
259 paths to device nodes like <literal>/dev/sda1</literal> with
260 <literal>PARTUUID=<replaceable>&lt;partition UUID&gt;</replaceable></literal>,
261 in <filename>/etc/fstab</filename>, to avoid a potential boot failure
262 in case the device node name has changed.</para>
263 </note>
264
265 <para>GRUB is an extremely powerful program and it provides a tremendous
266 number of options for booting from a wide variety of devices, operating
267 systems, and partition types. There are also many options for customization
268 such as graphical splash screens, playing sounds, mouse input, etc. The
269 details of these options are beyond the scope of this introduction.</para>
270
271 <caution><para>There is a command, <application>grub-mkconfig</application>, that
272 can write a configuration file automatically. It uses a set of scripts in
273 /etc/grub.d/ and will destroy any customizations that you make. These scripts
274 are designed primarily for non-source distributions and are not recommended for
275 LFS. If you install a commercial Linux distribution, there is a good chance
276 that this program will be run. Be sure to back up your grub.cfg file.</para></caution>
277
278 </sect2>
279
280</sect1>
Note: See TracBrowser for help on using the repository browser.