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