Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/filesystems/uefi-bootloaders/grub-setup.xml

    r8558044 re8d6204  
    99  <?dbhtml filename="grub-setup.html"?>
    1010
    11   <sect1info>
    12     <date>$Date$</date>
    13   </sect1info>
    1411
    1512  <title>Using GRUB to Set Up the Boot Process with UEFI</title>
     
    2017    <para>
    2118      BLFS does not have the essential packages to support Secure Boot. To
    22       set up the boot process with GRUB for UEFI installed in BLFS, Secure
     19      set up the boot process with GRUB and UEFI in BLFS, Secure
    2320      Boot must be turned off from the configuration interface of the
    2421      firmware.  Read the documentation provided by the manufacturer of your
     
    5451    <para>
    5552      Still as the <systemitem class="username">root</systemitem> user, use
    56       the <command>fdisk</command> utility to set the first parition
     53      the <command>fdisk</command> utility to set the first partition
    5754      of the USB flash drive to be an <quote>EFI system</quote> partition
    5855      (change <userinput>sdx</userinput> to the device node corresponding
     
    6259<screen role="nodump"><userinput>fdisk /dev/sdx</userinput>
    6360<literal>
    64 Welcome to fdisk (util-linux 2.36.2).
     61Welcome to fdisk (util-linux 2.38.1).
    6562Changes will remain in memory only, until you decide to write them.
    6663Be careful before using the write command.
     
    6865
    6966Command (m for help): </literal><userinput>t</userinput>
    70 <literal>Selected partition 1
    71 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'.
    7370
    7471Command (m for help): </literal><userinput>w</userinput>
     
    9087    </para>
    9188
    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>
    9390
    9491    <para>
     
    9996
    10097    <para>
    101       Now the USB flash drive can be used as a emergency boot disk on x86-64
     98      Now the USB flash drive can be used as an emergency boot disk on any x86-64
    10299      UEFI platform.  It will boot the system and show the GRUB shell.  Then you
    103       can type commands to boot your operating systems on the hard drive.
     100      can type commands to boot your operating system from the hard drive.
    104101      To learn how to select the boot device, read the manual of your
    105102      motherboard or laptop.
     
    117114
    118115<screen><literal>Processor type and features ---&gt;
    119   [*] EFI runtime service support                              [CONFIG_EFI]
    120   [*]   EFI stub support                                       [CONFIG_EFI_STUB]
    121 Firmware Drivers ---&gt;
    122   EFI (Extensible Firmware Interface) Support ---&gt;
    123     &lt; &gt; 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]
    125118Enable the block layer ---&gt;
    126119  Partition Types ---&gt;
    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]
    129122Device Drivers ---&gt;
     123  Firmware Drivers ---&gt;
     124    [*] Mark VGA/VBE/EFI FB as generic system framebuffer       [CONFIG_SYSFB_SIMPLEFB]
     125    EFI (Extensible Firmware Interface) Support ---&gt;
     126      &lt; &gt; EFI Variable Support via sysfs                        [CONFIG_EFI_VARS]
    130127  Graphics support ---&gt;
     128    &lt;*&gt; Direct Rendering Manager                                [CONFIG_DRM]
     129    [*] Enable legacy fbdev support for your modesetting driver [CONFIG_DRM_FBDEV_EMULATION]
     130    &lt;*&gt; Simple framebuffer driver                               [CONFIG_DRM_SIMPLEDRM]
    131131    Frame buffer Devices ---&gt;
    132       Support for frame buffer devices ---&gt;                    [CONFIG_FB]
    133         [*] EFI-based Framebuffer support                      [CONFIG_FB_EFI]
     132      &lt;*&gt; Support for frame buffer devices ---&gt;                 [CONFIG_FB]
    134133    Console display driver support ---&gt;
    135       [*] Framebuffer Console support                          [CONFIG_FRAMEBUFFER_CONSOLE]
     134      [*] Framebuffer Console support                           [CONFIG_FRAMEBUFFER_CONSOLE]
    136135File systems ---&gt;
     136  &lt;DOS/FAT/EXFAT/NT Filesystems ---&gt;
     137    &lt;*/M&gt; VFAT (Windows-95) fs support                          [CONFIG_VFAT_FS]
    137138  Pseudo filesystems ---&gt;
    138     &lt;*/M&gt; EFI Variable filesystem                              [CONFIG_EFIVAR_FS]</literal></screen>
     139    &lt;*/M&gt; EFI Variable filesystem                               [CONFIG_EFIVAR_FS]</literal></screen>
    139140
    140141    <variablelist>
    141       <title>The meaning of the configure options:</title>
     142      <title>The meaning of the configuration options:</title>
    142143
    143144      <varlistentry>
    144145        <term><parameter>CONFIG_EFI_STUB</parameter></term>
    145146        <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>
    150150        </listitem>
    151151      </varlistentry>
     
    161161
    162162      <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>
    164170        <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>
    168175        </listitem>
    169176      </varlistentry>
     
    177184
    178185    <para>
    179       On EFI based system, the bootloaders are installed in a special FAT32
     186      On EFI based systems, the bootloaders are installed in a special FAT32
    180187      partition called an <emphasis>EFI System Partition</emphasis> (ESP).
    181       If your system supports EFI, and a recent version of Linux
     188      If your system supports EFI, and a recent version of some Linux
    182189      distribution or Windows is pre-installed, it's likely that the ESP
    183       is already created.  As the
     190      has already been created.  As the
    184191      <systemitem class="username">root</systemitem> user, list all the
    185192      partitions on your hard drive (replace <userinput>sda</userinput>
     
    195202
    196203    <para>
    197       If the system or the hard drive is new, or it's a first time
    198       install an UEFI booted 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.
    199206      In that case, create a new partition, make a
    200207      <systemitem class="filesystem">vfat</systemitem> file system on it,
     
    205212    <warning>
    206213      <para>
    207         Some (old) UEFI implementations may demand the ESP to be the first
     214        Some (old) UEFI implementations may require the ESP to be the first
    208215        partition on the disk.
    209216      </para>
     
    233240
    234241  <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>
    235338    <title>Mount the EFI Variable File System</title>
    236339
    237340    <para>
    238341      The installation of GRUB on a UEFI platform requires that the EFI Variable
    239       file system, <systemitem class="filesystem">efivarfs</systemitem>, to be
     342      file system, <systemitem class="filesystem">efivarfs</systemitem>, is
    240343      mounted.  As the <systemitem class="username">root</systemitem> user,
    241344      mount it if it's not already mounted:
     
    248351        If the system is booted with UEFI and systemd,
    249352        <systemitem class="filesystem">efivarfs</systemitem> will be mounted
    250         automatically.  However in the LFS chroot environment it still needs to
     353        automatically.  However, in the LFS chroot environment it still needs to
    251354        be mounted manually.
    252355      </para>
     
    269372        <filename class="directory">/sys/firmware/efi</filename> will be
    270373        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.
    272377      </para>
    273378    </warning>
     
    291396    <para>
    292397      <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 ESP
     398      GRUB-2.06) so it will not use much space in the ESP.  A typical ESP
    294399      size is 100 MB (for Windows boot manager, which uses about 50 MB in
    295       the ESP). Once <filename>grubx64.efi</filename> loaded by the
    296       firmware, it will load GRUB modules in the 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.
    297402      The default location is
    298403      <filename class="directory">/boot/grub</filename>.
     
    316421
    317422    <para>
    318       Issue <command>efibootmgr</command> to recheck the EFI boot
     423      Issue the <command>efibootmgr | cut -f 1</command> command to recheck the EFI boot
    319424      configuration.  An example of the output is:
    320425    </para>
     
    366471fi
    367472
    368 menuentry "GNU/Linux, Linux 5.10.17-lfs-10.1"  {
    369   linux   /boot/vmlinuz-5.10.17-lfs-10.1 root=/dev/sda2 ro
     473menuentry "GNU/Linux, Linux 5.19.2-lfs-11.2"  {
     474  linux   /boot/vmlinuz-5.19.2-lfs-11.2 root=/dev/sda2 ro
    370475}
    371476
     
    377482    <para>
    378483      <literal>(hd0,2)</literal>, <literal>sda2</literal>, and
    379       <literal>5.10.17-lfs-10.1</literal> should be replaced to match your
     484      <literal>5.19.2-lfs-11.2</literal> must match your
    380485      configuration.
    381486    </para>
     
    383488    <note>
    384489      <para>
    385         From GRUB's perspective, the files are relative to the partition
    386         are used. If you used a separate /boot partition, remove /boot from the
     490        From GRUB's perspective, the files are relative to the partitions
     491        used. If you used a separate /boot partition, remove /boot from the
    387492        above paths (to kernel and to <filename>unicode.pf2</filename>). You
    388         will also need to change the set root line to point to the boot
     493        will also need to change the "set root" line to point to the boot
    389494        partition.
    390495      </para>
     
    408513<literal># Begin Windows addition
    409514
    410 menuentry "Windows 10" {
     515menuentry "Windows 11" {
    411516  insmod fat
    412517  insmod chain
     
    422527      in this case the Windows Boot Manager. You may put more usable tools
    423528      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.
    425530    </para>
    426531
Note: See TracChangeset for help on using the changeset viewer.