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