- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postlfs/filesystems/uefi-bootloaders/grub-setup.xml
r8558044 re8d6204 9 9 <?dbhtml filename="grub-setup.html"?> 10 10 11 <sect1info>12 <date>$Date$</date>13 </sect1info>14 11 15 12 <title>Using GRUB to Set Up the Boot Process with UEFI</title> … … 20 17 <para> 21 18 BLFS does not have the essential packages to support Secure Boot. To 22 set up the boot process with GRUB for UEFI installedin BLFS, Secure19 set up the boot process with GRUB and UEFI in BLFS, Secure 23 20 Boot must be turned off from the configuration interface of the 24 21 firmware. Read the documentation provided by the manufacturer of your … … 54 51 <para> 55 52 Still as the <systemitem class="username">root</systemitem> user, use 56 the <command>fdisk</command> utility to set the first par ition53 the <command>fdisk</command> utility to set the first partition 57 54 of the USB flash drive to be an <quote>EFI system</quote> partition 58 55 (change <userinput>sdx</userinput> to the device node corresponding … … 62 59 <screen role="nodump"><userinput>fdisk /dev/sdx</userinput> 63 60 <literal> 64 Welcome to fdisk (util-linux 2.3 6.2).61 Welcome to fdisk (util-linux 2.38.1). 65 62 Changes will remain in memory only, until you decide to write them. 66 63 Be careful before using the write command. … … 68 65 69 66 Command (m for help): </literal><userinput>t</userinput> 70 <literal> Selected partition 171 Hex code or alias (type L to list all): </literal><userinput>ef</userinput>72 <literal>Changed type of partition 'Linux ' to 'EFI (FAT-12/16/32)'.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'. 73 70 74 71 Command (m for help): </literal><userinput>w</userinput> … … 90 87 </para> 91 88 92 <screen role="nodump"><userinput>grub-install -- removable --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue/grub</userinput></screen>89 <screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue</userinput></screen> 93 90 94 91 <para> … … 99 96 100 97 <para> 101 Now the USB flash drive can be used as a emergency boot disk onx86-6498 Now the USB flash drive can be used as an emergency boot disk on any x86-64 102 99 UEFI platform. It will boot the system and show the GRUB shell. Then you 103 can type commands to boot your operating system s onthe hard drive.100 can type commands to boot your operating system from the hard drive. 104 101 To learn how to select the boot device, read the manual of your 105 102 motherboard or laptop. … … 117 114 118 115 <screen><literal>Processor type and features ---> 119 [*] EFI runtime service support [CONFIG_EFI] 120 [*] EFI stub support [CONFIG_EFI_STUB] 121 Firmware Drivers ---> 122 EFI (Extensible Firmware Interface) Support ---> 123 < > EFI Variable Support via sysfs [CONFIG_EFI_VARS] 124 [*] Export efi runtime maps to sysfs [CONFIG_EFI_RUNTIME_MAP] 116 [*] EFI runtime service support [CONFIG_EFI] 117 [*] EFI stub support [CONFIG_EFI_STUB] 125 118 Enable the block layer ---> 126 119 Partition Types ---> 127 [*] Advanced partition selection [CONFIG_PARTITION_ADVANCED]128 [*] EFI GUID Partition support [CONFIG_EFI_PARTITION]120 [*] Advanced partition selection [CONFIG_PARTITION_ADVANCED] 121 [*] EFI GUID Partition support [CONFIG_EFI_PARTITION] 129 122 Device Drivers ---> 123 Firmware Drivers ---> 124 [*] Mark VGA/VBE/EFI FB as generic system framebuffer [CONFIG_SYSFB_SIMPLEFB] 125 EFI (Extensible Firmware Interface) Support ---> 126 < > EFI Variable Support via sysfs [CONFIG_EFI_VARS] 130 127 Graphics support ---> 128 <*> Direct Rendering Manager [CONFIG_DRM] 129 [*] Enable legacy fbdev support for your modesetting driver [CONFIG_DRM_FBDEV_EMULATION] 130 <*> Simple framebuffer driver [CONFIG_DRM_SIMPLEDRM] 131 131 Frame buffer Devices ---> 132 Support for frame buffer devices ---> [CONFIG_FB] 133 [*] EFI-based Framebuffer support [CONFIG_FB_EFI] 132 <*> Support for frame buffer devices ---> [CONFIG_FB] 134 133 Console display driver support ---> 135 [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE]134 [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE] 136 135 File systems ---> 136 <DOS/FAT/EXFAT/NT Filesystems ---> 137 <*/M> VFAT (Windows-95) fs support [CONFIG_VFAT_FS] 137 138 Pseudo filesystems ---> 138 <*/M> EFI Variable filesystem [CONFIG_EFIVAR_FS]</literal></screen>139 <*/M> EFI Variable filesystem [CONFIG_EFIVAR_FS]</literal></screen> 139 140 140 141 <variablelist> 141 <title>The meaning of the configur eoptions:</title>142 <title>The meaning of the configuration options:</title> 142 143 143 144 <varlistentry> 144 145 <term><parameter>CONFIG_EFI_STUB</parameter></term> 145 146 <listitem> 146 <para>Although the EFI stub is designed to boot a kernel directly from 147 the UEFI firmware (without a bootloader like GRUB), GRUB needs the 148 kernel to be loaded to support the EFI handover protocol enabled by 149 this option.</para> 147 <para>On EFI systems, GRUB boots the Linux kernel by invoking the 148 EFI firmware to load it as an EFI application. So, EFI stub is 149 needed to wrap the kernel as an EFI application.</para> 150 150 </listitem> 151 151 </varlistentry> … … 161 161 162 162 <varlistentry> 163 <term><parameter>CONFIG_FB_EFI</parameter> and <parameter>CONFIG_FRAMEBUFFER_CONSOLE</parameter></term> 163 <term> 164 <parameter>CONFIG_SYSFB_SIMPLEFB</parameter>, 165 <parameter>CONFIG_DRM</parameter>, 166 <parameter>CONFIG_DRM_FBDEV_EMULATION</parameter>, 167 <parameter>CONFIG_DRM_SIMPLEDRM</parameter>, 168 <parameter>CONFIG_FB</parameter>, and 169 <parameter>CONFIG_FRAMEBUFFER_CONSOLE</parameter></term> 164 170 <listitem> 165 <para>The combination of these two options allows the kernel to 166 print debug messages (along with Tux logos) at the early stage of 167 the boot process with UEFI.</para> 171 <para>The combination of these options provides the Linux console 172 support on top of the UEFI framebuffer. To allow the kernel to 173 print debug messages at an early boot stage, they shouldn't be 174 built as kernel modules unless an initramfs will be used.</para> 168 175 </listitem> 169 176 </varlistentry> … … 177 184 178 185 <para> 179 On EFI based system , the bootloaders are installed in a special FAT32186 On EFI based systems, the bootloaders are installed in a special FAT32 180 187 partition called an <emphasis>EFI System Partition</emphasis> (ESP). 181 If your system supports EFI, and a recent version of Linux188 If your system supports EFI, and a recent version of some Linux 182 189 distribution or Windows is pre-installed, it's likely that the ESP 183 is alreadycreated. As the190 has already been created. As the 184 191 <systemitem class="username">root</systemitem> user, list all the 185 192 partitions on your hard drive (replace <userinput>sda</userinput> … … 195 202 196 203 <para> 197 If the system or the hard drive is new, or it's a first time198 install an UEFIbooted OS on the system, the ESP may not exist.204 If the system or the hard drive is new, or it's the first 205 installation of a UEFI-booted OS on the system, the ESP may not exist. 199 206 In that case, create a new partition, make a 200 207 <systemitem class="filesystem">vfat</systemitem> file system on it, … … 205 212 <warning> 206 213 <para> 207 Some (old) UEFI implementations may demandthe ESP to be the first214 Some (old) UEFI implementations may require the ESP to be the first 208 215 partition on the disk. 209 216 </para> … … 233 240 234 241 <sect2> 242 <title>Minimal Boot Configuration with GRUB and EFI</title> 243 244 <para> 245 On UEFI based systems, GRUB works by installing an EFI application 246 (a special kind of executable) into the ESP. The EFI firmware will 247 search boot loaders in EFI applications from boot entries recorded 248 in EFI variables, and additionally a hardcoded path 249 <filename>EFI/BOOT/BOOTX64.EFI</filename>. Normally, a boot loader 250 should be installed into a custom path and the path should be recorded 251 in the EFI variables. The use of the hardcoded path should be 252 avoided if possible. However, in some cases we have to use 253 the hardcoded path: 254 </para> 255 256 <itemizedlist> 257 <listitem> 258 <para> 259 The system is not booted with EFI yet, making EFI variables 260 inaccessible. 261 </para> 262 </listitem> 263 <listitem> 264 <para> 265 The EFI firmware is 64-bit but the LFS system is 32-bit, making 266 EFI variables inaccessible because the kernel cannot invoke EFI 267 runtime services with a different virtual address length. 268 </para> 269 </listitem> 270 <listitem> 271 <para> 272 LFS is built for a Live USB, so we cannot rely on EFI variables, 273 which are stored in NVRAM or EEPROM on the local machine. 274 </para> 275 </listitem> 276 <listitem> 277 <para> 278 You are unable or unwilling to install the 279 <application>efibootmgr</application> for manipulating boot 280 entries in EFI variables. 281 </para> 282 </listitem> 283 </itemizedlist> 284 285 <para> 286 In these cases, follow these instructions to install the GRUB EFI 287 application into the hardcoded path and make a minimal boot 288 configuration. Otherwise it's better to skip ahead and set up the 289 boot configuration normally. 290 </para> 291 292 <para> 293 To install GRUB with the EFI application in the hardcoded 294 path <filename>EFI/BOOT/BOOTX64.EFI</filename>, first ensure the boot 295 partition is mounted at <filename class="directory">/boot</filename> 296 and the ESP is mounted at 297 <filename class="directory">/boot/efi</filename>. Then, as the &root; 298 user, run the command: 299 </para> 300 301 <note> 302 <para> 303 This command will overwrite 304 <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename>. It may break a 305 bootloader already installed there. Back it up if you are not sure. 306 </para> 307 </note> 308 309 <screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable</userinput></screen> 310 311 <para> 312 This command will install the GRUB EFI application into the hardcoded path 313 <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename>, so the EFI 314 firmware can find and load it. The remaining GRUB files are installed 315 in the <filename class="directory">/boot/grub</filename> directory and 316 will be loaded by <filename>BOOTX64.EFI</filename> during system boot. 317 </para> 318 319 <note> 320 <para> 321 The EFI firmware usually prefers the EFI applications with a path 322 stored in EFI variables to the EFI 323 application at the hardcoded path. So you may need to invoke the 324 boot selection menu or firmware setting interface to select the 325 newly installed GRUB manually on the next boot. Read the manual of 326 your motherboard or laptop to learn how. 327 </para> 328 </note> 329 330 <para> 331 If you've followed the instructions in this section and set up a minimal boot 332 configuration, now skip ahead to 333 <quote>Creating the GRUB Configuration File</quote>. 334 </para> 335 </sect2> 336 337 <sect2> 235 338 <title>Mount the EFI Variable File System</title> 236 339 237 340 <para> 238 341 The installation of GRUB on a UEFI platform requires that the EFI Variable 239 file system, <systemitem class="filesystem">efivarfs</systemitem>, to be342 file system, <systemitem class="filesystem">efivarfs</systemitem>, is 240 343 mounted. As the <systemitem class="username">root</systemitem> user, 241 344 mount it if it's not already mounted: … … 248 351 If the system is booted with UEFI and systemd, 249 352 <systemitem class="filesystem">efivarfs</systemitem> will be mounted 250 automatically. However in the LFS chroot environment it still needs to353 automatically. However, in the LFS chroot environment it still needs to 251 354 be mounted manually. 252 355 </para> … … 269 372 <filename class="directory">/sys/firmware/efi</filename> will be 270 373 missing. In this case you should boot the system in UEFI mode with 271 the emergency boot disk created as above. 374 the emergency boot disk or using a minimal boot configuration created as 375 above, then mount 376 <systemitem class="filesystem">efivarfs</systemitem> and continue. 272 377 </para> 273 378 </warning> … … 291 396 <para> 292 397 <filename>grubx64.efi</filename> is very lightweight (136 KB with 293 GRUB-2.06 ~rc1) so it will not use much space in the ESP. A typical ESP398 GRUB-2.06) so it will not use much space in the ESP. A typical ESP 294 399 size is 100 MB (for Windows boot manager, which uses about 50 MB in 295 the ESP). Once <filename>grubx64.efi</filename> loaded by the296 firmware, it will load GRUB modules inthe boot partition.400 the ESP). Once <filename>grubx64.efi</filename> has been loaded by the 401 firmware, it will load GRUB modules from the boot partition. 297 402 The default location is 298 403 <filename class="directory">/boot/grub</filename>. … … 316 421 317 422 <para> 318 Issue <command>efibootmgr</command>to recheck the EFI boot423 Issue the <command>efibootmgr | cut -f 1</command> command to recheck the EFI boot 319 424 configuration. An example of the output is: 320 425 </para> … … 366 471 fi 367 472 368 menuentry "GNU/Linux, Linux 5.1 0.17-lfs-10.1" {369 linux /boot/vmlinuz-5.1 0.17-lfs-10.1root=/dev/sda2 ro473 menuentry "GNU/Linux, Linux 5.19.2-lfs-11.2" { 474 linux /boot/vmlinuz-5.19.2-lfs-11.2 root=/dev/sda2 ro 370 475 } 371 476 … … 377 482 <para> 378 483 <literal>(hd0,2)</literal>, <literal>sda2</literal>, and 379 <literal>5.1 0.17-lfs-10.1</literal> should be replaced tomatch your484 <literal>5.19.2-lfs-11.2</literal> must match your 380 485 configuration. 381 486 </para> … … 383 488 <note> 384 489 <para> 385 From GRUB's perspective, the files are relative to the partition 386 areused. If you used a separate /boot partition, remove /boot from the490 From GRUB's perspective, the files are relative to the partitions 491 used. If you used a separate /boot partition, remove /boot from the 387 492 above paths (to kernel and to <filename>unicode.pf2</filename>). You 388 will also need to change the set rootline to point to the boot493 will also need to change the "set root" line to point to the boot 389 494 partition. 390 495 </para> … … 408 513 <literal># Begin Windows addition 409 514 410 menuentry "Windows 1 0" {515 menuentry "Windows 11" { 411 516 insmod fat 412 517 insmod chain … … 422 527 in this case the Windows Boot Manager. You may put more usable tools 423 528 in EFI executable format (for example, an EFI shell) into the ESP and 424 create GRUB entries for them .529 create GRUB entries for them, as well. 425 530 </para> 426 531
Note:
See TracChangeset
for help on using the changeset viewer.