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