[ab4fdfc] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[756a787] | 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;
|
---|
[dece8f5] | 6 |
|
---|
| 7 | <!ENTITY lfs-kernel-ver "6.10.5-lfs-12.2">
|
---|
[756a787] | 8 | ]>
|
---|
| 9 |
|
---|
| 10 | <sect1 id="grub-setup" xreflabel="Using GRUB to Set Up the Boot Process with UEFI">
|
---|
| 11 | <?dbhtml filename="grub-setup.html"?>
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | <title>Using GRUB to Set Up the Boot Process with UEFI</title>
|
---|
| 15 |
|
---|
| 16 | <sect2>
|
---|
| 17 | <title>Turn Off Secure Boot</title>
|
---|
| 18 |
|
---|
| 19 | <para>
|
---|
[d5cc78a] | 20 | BLFS does not have the essential packages to support Secure Boot. To
|
---|
[c8391c3d] | 21 | set up the boot process with GRUB and UEFI in BLFS, Secure
|
---|
[756a787] | 22 | Boot must be turned off from the configuration interface of the
|
---|
| 23 | firmware. Read the documentation provided by the manufacturer of your
|
---|
| 24 | system to find out how.
|
---|
| 25 | </para>
|
---|
| 26 | </sect2>
|
---|
| 27 |
|
---|
[31ef72a9] | 28 | <sect2 role="kernel" id="uefi-kernel">
|
---|
| 29 | <title>Kernel Configuration for UEFI support</title>
|
---|
| 30 |
|
---|
| 31 | <para>
|
---|
| 32 | Enable the following options in the kernel configuration and recompile
|
---|
| 33 | the kernel if necessary:
|
---|
| 34 | </para>
|
---|
| 35 |
|
---|
| 36 | <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
---|
| 37 | href="grub-setup-kernel.xml"/>
|
---|
| 38 |
|
---|
| 39 | <variablelist>
|
---|
| 40 | <title>The meaning of the configuration options:</title>
|
---|
| 41 |
|
---|
| 42 | <varlistentry>
|
---|
| 43 | <term><parameter>CONFIG_PARTITION_ADVANCED</parameter></term>
|
---|
| 44 | <listitem>
|
---|
| 45 | <para>If it's not enabled,
|
---|
| 46 | <parameter>CONFIG_EFI_PARTITION</parameter> will be enabled
|
---|
| 47 | automatically. But when it's enabled, you must set
|
---|
| 48 | <parameter>CONFIG_EFI_PARTITION</parameter> to enabled as
|
---|
| 49 | well.</para>
|
---|
| 50 | </listitem>
|
---|
| 51 | </varlistentry>
|
---|
| 52 |
|
---|
| 53 | <varlistentry>
|
---|
| 54 | <term>
|
---|
| 55 | <parameter>CONFIG_SYSFB_SIMPLEFB</parameter>,
|
---|
| 56 | <parameter>CONFIG_DRM</parameter>,
|
---|
| 57 | <parameter>CONFIG_DRM_FBDEV_EMULATION</parameter>,
|
---|
| 58 | <parameter>CONFIG_DRM_SIMPLEDRM</parameter>,
|
---|
| 59 | <parameter>CONFIG_FB</parameter>, and
|
---|
| 60 | <parameter>CONFIG_FRAMEBUFFER_CONSOLE</parameter></term>
|
---|
| 61 | <listitem>
|
---|
| 62 | <para>The combination of these options provides the Linux console
|
---|
| 63 | support on top of the UEFI framebuffer. To allow the kernel to
|
---|
| 64 | print debug messages at an early boot stage, they shouldn't be
|
---|
| 65 | built as kernel modules unless an initramfs will be used.</para>
|
---|
| 66 | </listitem>
|
---|
| 67 | </varlistentry>
|
---|
| 68 |
|
---|
| 69 | </variablelist>
|
---|
| 70 |
|
---|
| 71 | <indexterm zone="grub-setup uefi-kernel">
|
---|
| 72 | <primary sortas="d-uefi">UEFI</primary>
|
---|
| 73 | </indexterm>
|
---|
| 74 | </sect2>
|
---|
| 75 |
|
---|
[756a787] | 76 | <sect2>
|
---|
| 77 | <title>Create an Emergency Boot Disk</title>
|
---|
| 78 |
|
---|
| 79 | <para>
|
---|
| 80 | Ensure that an emergency boot disk is ready to <quote>rescue</quote>
|
---|
[d5cc78a] | 81 | the system in case the system becomes un-bootable. To make an
|
---|
| 82 | emergency boot disk with GRUB for an EFI based system, find a spare
|
---|
[756a787] | 83 | USB flash drive and create a
|
---|
| 84 | <systemitem class="filesystem">vfat</systemitem> file system on it.
|
---|
| 85 | Install <xref linkend="dosfstools"/> first, then
|
---|
| 86 | as the <systemitem class="username">root</systemitem> user:
|
---|
| 87 | </para>
|
---|
| 88 |
|
---|
| 89 | <warning>
|
---|
| 90 | <para>
|
---|
| 91 | The following command will erase all directories and files in the
|
---|
| 92 | partition. Make sure your USB flash drive contains no data which
|
---|
| 93 | will be needed, and change <userinput>sdx1</userinput> to the
|
---|
| 94 | device node corresponding to the first partition of the USB flash
|
---|
| 95 | drive. Be careful not to overwrite your hard drive with a typo!
|
---|
| 96 | </para>
|
---|
| 97 | </warning>
|
---|
| 98 |
|
---|
| 99 | <screen role="nodump"><userinput>mkfs.vfat /dev/sdx1</userinput></screen>
|
---|
| 100 |
|
---|
| 101 | <para>
|
---|
| 102 | Still as the <systemitem class="username">root</systemitem> user, use
|
---|
[b9c353b] | 103 | the <command>fdisk</command> utility to set the first partition
|
---|
[756a787] | 104 | of the USB flash drive to be an <quote>EFI system</quote> partition
|
---|
| 105 | (change <userinput>sdx</userinput> to the device node corresponding
|
---|
| 106 | to your USB flash drive):
|
---|
| 107 | </para>
|
---|
| 108 |
|
---|
| 109 | <screen role="nodump"><userinput>fdisk /dev/sdx</userinput>
|
---|
| 110 | <literal>
|
---|
[3a0f422] | 111 | Welcome to fdisk (util-linux 2.39.1).
|
---|
[756a787] | 112 | Changes will remain in memory only, until you decide to write them.
|
---|
| 113 | Be careful before using the write command.
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | Command (m for help): </literal><userinput>t</userinput>
|
---|
[43397b0e] | 117 | <literal>Partition number (1-9, default 9): </literal><userinput>1</userinput>
|
---|
| 118 | <literal>Partition type or alias (type L to list all): </literal><userinput>uefi</userinput>
|
---|
| 119 | <literal>Changed type of partition 'Linux filesystem' to 'EFI System'.
|
---|
[756a787] | 120 |
|
---|
| 121 | Command (m for help): </literal><userinput>w</userinput>
|
---|
| 122 | <literal>The partition table has been altered.
|
---|
| 123 | Syncing disks.</literal></screen>
|
---|
| 124 |
|
---|
| 125 | <para>
|
---|
| 126 | Still as the <systemitem class="username">root</systemitem> user,
|
---|
| 127 | create a mount point for the EFI partition on the USB flash drive
|
---|
| 128 | and mount it:
|
---|
| 129 | </para>
|
---|
| 130 |
|
---|
[31ef72a9] | 131 | <screen role="nodump"><userinput>mount --mkdir -v -t vfat /dev/sdx1 -o codepage=437,iocharset=iso8859-1 \
|
---|
| 132 | /mnt/rescue</userinput></screen>
|
---|
[756a787] | 133 |
|
---|
| 134 | <para>
|
---|
| 135 | Install GRUB for EFI on the partition:
|
---|
| 136 | </para>
|
---|
| 137 |
|
---|
[31ef72a9] | 138 | <screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable \
|
---|
| 139 | --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue</userinput></screen>
|
---|
[756a787] | 140 |
|
---|
| 141 | <para>
|
---|
| 142 | Unmount the partition:
|
---|
| 143 | </para>
|
---|
| 144 |
|
---|
| 145 | <screen role="nodump"><userinput>umount /mnt/rescue</userinput></screen>
|
---|
| 146 |
|
---|
| 147 | <para>
|
---|
[c8391c3d] | 148 | Now the USB flash drive can be used as an emergency boot disk on any x86-64
|
---|
[a646aaa0] | 149 | UEFI platform. To learn how to select this flash drive as the boot
|
---|
| 150 | device, read the manual of your motherboard or laptop.
|
---|
| 151 | It will boot the system and show the GRUB shell. Then you
|
---|
[c8391c3d] | 152 | can type commands to boot your operating system from the hard drive.
|
---|
[756a787] | 153 | </para>
|
---|
| 154 |
|
---|
| 155 | </sect2>
|
---|
| 156 |
|
---|
| 157 | <sect2>
|
---|
| 158 | <title>Find or Create the EFI System Partition</title>
|
---|
| 159 |
|
---|
| 160 | <para>
|
---|
[c8391c3d] | 161 | On EFI based systems, the bootloaders are installed in a special FAT32
|
---|
[d5cc78a] | 162 | partition called an <emphasis>EFI System Partition</emphasis> (ESP).
|
---|
[c8391c3d] | 163 | If your system supports EFI, and a recent version of some Linux
|
---|
[756a787] | 164 | distribution or Windows is pre-installed, it's likely that the ESP
|
---|
[c8391c3d] | 165 | has already been created. As the
|
---|
[756a787] | 166 | <systemitem class="username">root</systemitem> user, list all the
|
---|
| 167 | partitions on your hard drive (replace <userinput>sda</userinput>
|
---|
[d5cc78a] | 168 | with the device corresponding to the appropriate hard drive):
|
---|
[756a787] | 169 | </para>
|
---|
| 170 |
|
---|
| 171 | <screen role="nodump"><userinput>fdisk -l /dev/sda</userinput></screen>
|
---|
| 172 |
|
---|
| 173 | <para>
|
---|
| 174 | The <quote>Type</quote> column of the ESP should be
|
---|
| 175 | <literal>EFI System</literal>.
|
---|
| 176 | </para>
|
---|
| 177 |
|
---|
| 178 | <para>
|
---|
[c8391c3d] | 179 | If the system or the hard drive is new, or it's the first
|
---|
| 180 | installation of a UEFI-booted OS on the system, the ESP may not exist.
|
---|
[7befd975] | 181 | In that case, install <xref linkend='dosfstools'/> first. Then create
|
---|
| 182 | a new partition, make a
|
---|
[756a787] | 183 | <systemitem class="filesystem">vfat</systemitem> file system on it,
|
---|
[af2b317] | 184 | and set the partition type to <quote>EFI system.</quote> See the
|
---|
[756a787] | 185 | instructions for the emergency boot device above as a reference.
|
---|
| 186 | </para>
|
---|
| 187 |
|
---|
| 188 | <warning>
|
---|
| 189 | <para>
|
---|
[c8391c3d] | 190 | Some (old) UEFI implementations may require the ESP to be the first
|
---|
[756a787] | 191 | partition on the disk.
|
---|
| 192 | </para>
|
---|
| 193 | </warning>
|
---|
| 194 |
|
---|
| 195 | <para>
|
---|
[e282f70] | 196 | Now, as the <systemitem class="username">root</systemitem> user,
|
---|
| 197 | create the mount point for the ESP, and mount it (replace
|
---|
[756a787] | 198 | <userinput>sda1</userinput> with the device node corresponding to
|
---|
| 199 | the ESP):
|
---|
| 200 | </para>
|
---|
| 201 |
|
---|
[31ef72a9] | 202 | <screen role="nodump"><userinput>mount --mkdir -v -t vfat /dev/sda1 -o codepage=437,iocharset=iso8859-1 \
|
---|
| 203 | /boot/efi</userinput></screen>
|
---|
[756a787] | 204 |
|
---|
| 205 | <para>
|
---|
[31ef72a9] | 206 | If you want to mount the ESP automatically during system boot,
|
---|
| 207 | as the &root; user, add an entry for the ESP into
|
---|
| 208 | <filename>/etc/fstab</filename>:
|
---|
[756a787] | 209 | </para>
|
---|
| 210 |
|
---|
[e282f70] | 211 | <screen role="nodump"><userinput>cat >> /etc/fstab << EOF</userinput>
|
---|
| 212 | <literal>/dev/sda1 /boot/efi vfat codepage=437,iocharset=iso8859-1 0 1</literal>
|
---|
| 213 | <userinput>EOF</userinput></screen>
|
---|
[756a787] | 214 |
|
---|
| 215 | </sect2>
|
---|
| 216 |
|
---|
[6db606f] | 217 | <sect2>
|
---|
| 218 | <title>Minimal Boot Configuration with GRUB and EFI</title>
|
---|
| 219 |
|
---|
| 220 | <para>
|
---|
| 221 | On UEFI based systems, GRUB works by installing an EFI application
|
---|
| 222 | (a special kind of executable) into the ESP. The EFI firmware will
|
---|
| 223 | search boot loaders in EFI applications from boot entries recorded
|
---|
| 224 | in EFI variables, and additionally a hardcoded path
|
---|
| 225 | <filename>EFI/BOOT/BOOTX64.EFI</filename>. Normally, a boot loader
|
---|
| 226 | should be installed into a custom path and the path should be recorded
|
---|
[c8391c3d] | 227 | in the EFI variables. The use of the hardcoded path should be
|
---|
| 228 | avoided if possible. However, in some cases we have to use
|
---|
[6db606f] | 229 | the hardcoded path:
|
---|
| 230 | </para>
|
---|
| 231 |
|
---|
| 232 | <itemizedlist>
|
---|
| 233 | <listitem>
|
---|
| 234 | <para>
|
---|
[c8391c3d] | 235 | The system is not booted with EFI yet, making EFI variables
|
---|
[6db606f] | 236 | inaccessible.
|
---|
| 237 | </para>
|
---|
| 238 | </listitem>
|
---|
| 239 | <listitem>
|
---|
| 240 | <para>
|
---|
[c8391c3d] | 241 | The EFI firmware is 64-bit but the LFS system is 32-bit, making
|
---|
[6db606f] | 242 | EFI variables inaccessible because the kernel cannot invoke EFI
|
---|
| 243 | runtime services with a different virtual address length.
|
---|
| 244 | </para>
|
---|
| 245 | </listitem>
|
---|
| 246 | <listitem>
|
---|
| 247 | <para>
|
---|
[c8391c3d] | 248 | LFS is built for a Live USB, so we cannot rely on EFI variables,
|
---|
| 249 | which are stored in NVRAM or EEPROM on the local machine.
|
---|
[6db606f] | 250 | </para>
|
---|
| 251 | </listitem>
|
---|
| 252 | <listitem>
|
---|
| 253 | <para>
|
---|
[c8391c3d] | 254 | You are unable or unwilling to install the
|
---|
[6db606f] | 255 | <application>efibootmgr</application> for manipulating boot
|
---|
| 256 | entries in EFI variables.
|
---|
| 257 | </para>
|
---|
| 258 | </listitem>
|
---|
| 259 | </itemizedlist>
|
---|
| 260 |
|
---|
| 261 | <para>
|
---|
[c8391c3d] | 262 | In these cases, follow these instructions to install the GRUB EFI
|
---|
[6db606f] | 263 | application into the hardcoded path and make a minimal boot
|
---|
[c8391c3d] | 264 | configuration. Otherwise it's better to skip ahead and set up the
|
---|
| 265 | boot configuration normally.
|
---|
[6db606f] | 266 | </para>
|
---|
| 267 |
|
---|
| 268 | <para>
|
---|
[c8391c3d] | 269 | To install GRUB with the EFI application in the hardcoded
|
---|
[6db606f] | 270 | path <filename>EFI/BOOT/BOOTX64.EFI</filename>, first ensure the boot
|
---|
[b38aed5] | 271 | partition is mounted at <filename class="directory">/boot</filename>
|
---|
[c8391c3d] | 272 | and the ESP is mounted at
|
---|
| 273 | <filename class="directory">/boot/efi</filename>. Then, as the &root;
|
---|
[6db606f] | 274 | user, run the command:
|
---|
| 275 | </para>
|
---|
| 276 |
|
---|
| 277 | <note>
|
---|
| 278 | <para>
|
---|
[c8391c3d] | 279 | This command will overwrite
|
---|
[6db606f] | 280 | <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename>. It may break a
|
---|
| 281 | bootloader already installed there. Back it up if you are not sure.
|
---|
| 282 | </para>
|
---|
| 283 | </note>
|
---|
| 284 |
|
---|
| 285 | <screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable</userinput></screen>
|
---|
| 286 |
|
---|
| 287 | <para>
|
---|
[c8391c3d] | 288 | This command will install the GRUB EFI application into the hardcoded path
|
---|
[6db606f] | 289 | <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename>, so the EFI
|
---|
| 290 | firmware can find and load it. The remaining GRUB files are installed
|
---|
[c8391c3d] | 291 | in the <filename class="directory">/boot/grub</filename> directory and
|
---|
[6db606f] | 292 | will be loaded by <filename>BOOTX64.EFI</filename> during system boot.
|
---|
| 293 | </para>
|
---|
| 294 |
|
---|
| 295 | <note>
|
---|
| 296 | <para>
|
---|
[c8391c3d] | 297 | The EFI firmware usually prefers the EFI applications with a path
|
---|
| 298 | stored in EFI variables to the EFI
|
---|
[6db606f] | 299 | application at the hardcoded path. So you may need to invoke the
|
---|
| 300 | boot selection menu or firmware setting interface to select the
|
---|
| 301 | newly installed GRUB manually on the next boot. Read the manual of
|
---|
[c8391c3d] | 302 | your motherboard or laptop to learn how.
|
---|
[6db606f] | 303 | </para>
|
---|
| 304 | </note>
|
---|
| 305 |
|
---|
| 306 | <para>
|
---|
[c8391c3d] | 307 | If you've followed the instructions in this section and set up a minimal boot
|
---|
| 308 | configuration, now skip ahead to
|
---|
[af2b317] | 309 | <quote>Creating the GRUB Configuration File.</quote>
|
---|
[6db606f] | 310 | </para>
|
---|
| 311 | </sect2>
|
---|
| 312 |
|
---|
[756a787] | 313 | <sect2>
|
---|
| 314 | <title>Mount the EFI Variable File System</title>
|
---|
| 315 |
|
---|
| 316 | <para>
|
---|
[d5cc78a] | 317 | The installation of GRUB on a UEFI platform requires that the EFI Variable
|
---|
[c8391c3d] | 318 | file system, <systemitem class="filesystem">efivarfs</systemitem>, is
|
---|
[564a569] | 319 | mounted. As the <systemitem class="username">root</systemitem> user,
|
---|
| 320 | mount it if it's not already mounted:
|
---|
[756a787] | 321 | </para>
|
---|
| 322 |
|
---|
[564a569] | 323 | <screen role="nodump"><userinput>mountpoint /sys/firmware/efi/efivars || mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars</userinput></screen>
|
---|
[756a787] | 324 |
|
---|
| 325 | <note revision="systemd">
|
---|
| 326 | <para>
|
---|
| 327 | If the system is booted with UEFI and systemd,
|
---|
| 328 | <systemitem class="filesystem">efivarfs</systemitem> will be mounted
|
---|
[c8391c3d] | 329 | automatically. However, in the LFS chroot environment it still needs to
|
---|
[756a787] | 330 | be mounted manually.
|
---|
| 331 | </para>
|
---|
| 332 | </note>
|
---|
| 333 |
|
---|
| 334 | <para revision="sysv">
|
---|
[d5cc78a] | 335 | Now add an entry for the
|
---|
[756a787] | 336 | <systemitem class="filesystem">efivarfs</systemitem> in
|
---|
[d5cc78a] | 337 | <filename>/etc/fstab</filename> so it will be mounted automatically
|
---|
[756a787] | 338 | during system boot:
|
---|
| 339 | </para>
|
---|
| 340 |
|
---|
| 341 | <screen revision="sysv" role="nodump"><userinput>cat >> /etc/fstab << EOF</userinput>
|
---|
[6ca17c82] | 342 | <literal>efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0</literal>
|
---|
[756a787] | 343 | <userinput>EOF</userinput></screen>
|
---|
| 344 |
|
---|
| 345 | <warning>
|
---|
| 346 | <para>
|
---|
| 347 | If the system is not booted with UEFI, the directory
|
---|
| 348 | <filename class="directory">/sys/firmware/efi</filename> will be
|
---|
| 349 | missing. In this case you should boot the system in UEFI mode with
|
---|
[c8391c3d] | 350 | the emergency boot disk or using a minimal boot configuration created as
|
---|
[6db606f] | 351 | above, then mount
|
---|
| 352 | <systemitem class="filesystem">efivarfs</systemitem> and continue.
|
---|
[756a787] | 353 | </para>
|
---|
| 354 | </warning>
|
---|
| 355 | </sect2>
|
---|
| 356 |
|
---|
| 357 | <sect2>
|
---|
| 358 | <title>Setting Up the Configuration</title>
|
---|
| 359 |
|
---|
| 360 | <para>
|
---|
| 361 | On UEFI based systems, GRUB works by installing an EFI application
|
---|
[d5cc78a] | 362 | (a special kind of executable) into
|
---|
[756a787] | 363 | <filename class="directory">/boot/efi/EFI/[id]/grubx64.efi</filename>,
|
---|
| 364 | where <filename class="directory">/boot/efi</filename> is the mount
|
---|
| 365 | point of the ESP, and <literal>[id]</literal> is replaced with an
|
---|
| 366 | identifier specified in the <command>grub-install</command> command
|
---|
[d5cc78a] | 367 | line. GRUB will create an entry in the EFI variables containing
|
---|
| 368 | the path <literal>EFI/[id]/grubx64.efi</literal> so the EFI firmware
|
---|
[756a787] | 369 | can find <filename>grubx64.efi</filename> and load it.
|
---|
| 370 | </para>
|
---|
| 371 |
|
---|
| 372 | <para>
|
---|
| 373 | <filename>grubx64.efi</filename> is very lightweight (136 KB with
|
---|
[16f7f0e] | 374 | GRUB-2.06) so it will not use much space in the ESP. A typical ESP
|
---|
[d5cc78a] | 375 | size is 100 MB (for Windows boot manager, which uses about 50 MB in
|
---|
[c8391c3d] | 376 | the ESP). Once <filename>grubx64.efi</filename> has been loaded by the
|
---|
| 377 | firmware, it will load GRUB modules from the boot partition.
|
---|
[756a787] | 378 | The default location is
|
---|
| 379 | <filename class="directory">/boot/grub</filename>.
|
---|
| 380 | </para>
|
---|
| 381 |
|
---|
| 382 | <para>
|
---|
| 383 | As the <systemitem class="username">root</systemitem> user, install
|
---|
| 384 | the GRUB files into <filename>/boot/efi/EFI/LFS/grubx64.efi</filename>
|
---|
[d5cc78a] | 385 | and <filename class="directory">/boot/grub</filename>. Then set up the
|
---|
[756a787] | 386 | boot entry in the EFI variables:
|
---|
| 387 | </para>
|
---|
| 388 |
|
---|
| 389 | <screen role="nodump"><userinput>grub-install --bootloader-id=LFS --recheck</userinput></screen>
|
---|
| 390 |
|
---|
| 391 | <para>
|
---|
| 392 | If the installation is successful, the output should be:
|
---|
| 393 | </para>
|
---|
| 394 |
|
---|
| 395 | <screen role="nodump"><literal>Installing for x86_64-efi platform.
|
---|
| 396 | Installation finished. No error reported.</literal></screen>
|
---|
| 397 |
|
---|
| 398 | <para>
|
---|
[c8391c3d] | 399 | Issue the <command>efibootmgr | cut -f 1</command> command to recheck the EFI boot
|
---|
[756a787] | 400 | configuration. An example of the output is:
|
---|
| 401 | </para>
|
---|
| 402 |
|
---|
| 403 | <screen role="nodump"><literal>BootCurrent: 0000
|
---|
| 404 | Timeout: 1 seconds
|
---|
| 405 | BootOrder: 0005,0000,0002,0001,0003,0004
|
---|
| 406 | Boot0000* ARCH
|
---|
| 407 | Boot0001* UEFI:CD/DVD Drive
|
---|
| 408 | Boot0002* Windows Boot Manager
|
---|
| 409 | Boot0003* UEFI:Removable Device
|
---|
| 410 | Boot0004* UEFI:Network Device
|
---|
| 411 | Boot0005* LFS</literal></screen>
|
---|
| 412 |
|
---|
| 413 | <para>
|
---|
[d5cc78a] | 414 | Note that <literal>0005</literal> is the first in the
|
---|
[756a787] | 415 | <literal>BootOrder</literal>, and <literal>Boot0005</literal>
|
---|
[8558044] | 416 | is <literal>LFS</literal>. This means that on the next boot, the
|
---|
[d5cc78a] | 417 | version of GRUB installed by LFS will be used to boot the system.
|
---|
[756a787] | 418 | </para>
|
---|
| 419 |
|
---|
| 420 | </sect2>
|
---|
| 421 |
|
---|
| 422 | <sect2>
|
---|
| 423 | <title>Creating the GRUB Configuration File</title>
|
---|
| 424 |
|
---|
| 425 | <indexterm zone="grub-setup grub-video">
|
---|
| 426 | <primary sortas="e-boot-grub-grub-cfg">/boot/grub/grub.cfg</primary>
|
---|
| 427 | </indexterm>
|
---|
| 428 |
|
---|
| 429 | <para>
|
---|
| 430 | Generate <filename>/boot/grub/grub.cfg</filename> to configure the
|
---|
| 431 | boot menu of GRUB:
|
---|
| 432 | </para>
|
---|
| 433 |
|
---|
| 434 | <screen role="nodump"><userinput>cat > /boot/grub/grub.cfg << EOF</userinput>
|
---|
| 435 | <literal># Begin /boot/grub/grub.cfg
|
---|
| 436 | set default=0
|
---|
| 437 | set timeout=5
|
---|
| 438 |
|
---|
| 439 | insmod part_gpt
|
---|
| 440 | insmod ext2
|
---|
| 441 | set root=(hd0,2)
|
---|
| 442 |
|
---|
[0375659] | 443 | insmod efi_gop<!-- to editors: do not use all_video which -->
|
---|
| 444 | insmod efi_uga<!-- breaks Linux simpledrm driver in QEMU -->
|
---|
[756a787] | 445 | if loadfont /boot/grub/fonts/unicode.pf2; then
|
---|
| 446 | terminal_output gfxterm
|
---|
| 447 | fi
|
---|
| 448 |
|
---|
[dece8f5] | 449 | menuentry "GNU/Linux, Linux &lfs-kernel-ver;" {
|
---|
| 450 | linux /boot/vmlinuz-&lfs-kernel-ver; root=/dev/sda2 ro
|
---|
[756a787] | 451 | }
|
---|
| 452 |
|
---|
| 453 | menuentry "Firmware Setup" {
|
---|
| 454 | fwsetup
|
---|
| 455 | }</literal>
|
---|
| 456 | <userinput>EOF</userinput></screen>
|
---|
| 457 |
|
---|
| 458 | <para>
|
---|
[9414365d] | 459 | Refer to <ulink url='&lfs-root;/chapter10/grub.html'>the LFS
|
---|
| 460 | book</ulink> for the basic knowledge about the
|
---|
| 461 | <filename>grub.cfg</filename> file.
|
---|
[756a787] | 462 | <literal>(hd0,2)</literal>, <literal>sda2</literal>, and
|
---|
[dece8f5] | 463 | <literal>&lfs-kernel-ver;</literal> must match your
|
---|
[756a787] | 464 | configuration.
|
---|
| 465 | </para>
|
---|
| 466 |
|
---|
[9414365d] | 467 | <para>
|
---|
[59d2215] | 468 | The <command>insmod efi_gop</command> and
|
---|
| 469 | <command>insmod efi_uga</command> directives load two modules for
|
---|
| 470 | EFI-based video support. On most systems the
|
---|
| 471 | <literal>efi_gop</literal> module is enough. The
|
---|
| 472 | <literal>efi_uga</literal> module is only useful for legacy systems,
|
---|
| 473 | but it's harmless to load it anyway. The video support is needed for
|
---|
| 474 | the <command>terminal_output gfxterm</command> directive to really
|
---|
| 475 | work.
|
---|
[9414365d] | 476 | </para>
|
---|
| 477 |
|
---|
| 478 | <para>
|
---|
| 479 | The <command>terminal_output gfxterm</command> directive changes
|
---|
| 480 | the display resolution of the GRUB menu to match your display device.
|
---|
| 481 | It will break the rendering if the <filename>unicode.pf2</filename>
|
---|
| 482 | font data file is not loaded, so it's guarded by a
|
---|
| 483 | <command>if</command> directive.
|
---|
| 484 | </para>
|
---|
| 485 |
|
---|
[756a787] | 486 | <note>
|
---|
| 487 | <para>
|
---|
[c8391c3d] | 488 | From GRUB's perspective, the files are relative to the partitions
|
---|
| 489 | used. If you used a separate /boot partition, remove /boot from the
|
---|
[756a787] | 490 | above paths (to kernel and to <filename>unicode.pf2</filename>). You
|
---|
[c8391c3d] | 491 | will also need to change the "set root" line to point to the boot
|
---|
[756a787] | 492 | partition.
|
---|
| 493 | </para>
|
---|
| 494 | </note>
|
---|
| 495 |
|
---|
| 496 | <para>
|
---|
| 497 | The <literal>Firmware Setup</literal> entry can be used to enter the
|
---|
| 498 | configuration interface provided by the firmware (sometimes called
|
---|
[9039d65] | 499 | <quote>BIOS configuration</quote>).
|
---|
[756a787] | 500 | </para>
|
---|
| 501 | </sect2>
|
---|
| 502 |
|
---|
| 503 | <sect2>
|
---|
| 504 | <title>Dual-booting with Windows</title>
|
---|
| 505 |
|
---|
| 506 | <para>
|
---|
| 507 | Add a menu entry for Windows into <filename>grub.cfg</filename>:
|
---|
| 508 | </para>
|
---|
| 509 |
|
---|
| 510 | <screen role="nodump"><userinput>cat >> /boot/grub/grub.cfg << EOF</userinput>
|
---|
| 511 | <literal># Begin Windows addition
|
---|
| 512 |
|
---|
[16f7f0e] | 513 | menuentry "Windows 11" {
|
---|
[756a787] | 514 | insmod fat
|
---|
| 515 | insmod chain
|
---|
| 516 | set root=(hd0,1)
|
---|
| 517 | chainloader /EFI/Microsoft/Boot/bootmgfw.efi
|
---|
| 518 | }</literal>
|
---|
| 519 | <userinput>EOF</userinput></screen>
|
---|
| 520 |
|
---|
| 521 | <para>
|
---|
| 522 | <literal>(hd0,1)</literal> should be replaced with the GRUB
|
---|
[d5cc78a] | 523 | designated name for the ESP. The <literal>chainloader</literal>
|
---|
[756a787] | 524 | directive can be used to tell GRUB to run another EFI executable,
|
---|
| 525 | in this case the Windows Boot Manager. You may put more usable tools
|
---|
[8558044] | 526 | in EFI executable format (for example, an EFI shell) into the ESP and
|
---|
[c8391c3d] | 527 | create GRUB entries for them, as well.
|
---|
[756a787] | 528 | </para>
|
---|
| 529 |
|
---|
| 530 | </sect2>
|
---|
| 531 |
|
---|
| 532 | </sect1>
|
---|