| Newsgroups |
gmane.linux.lfs.book |
| Message-ID |
<[email protected]> |
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch zeckma/uefi-support
in repository lfs.
commit 1224be562fc5cb83dc019ac995adab9e2dbebcf3
Author: Zeckmathederg <[email protected]>
AuthorDate: Mon Feb 2 21:02:54 2026 -0700
UEFI: Pull in Xi's changes.
---
chapter08/gcc.xml | 11 ++++
chapter08/grub.xml | 69 +++++++++++++++++-----
chapter10/grub.xml | 170 ++++++++++++++++++++++++++++++++++++++---------------
3 files changed, 188 insertions(+), 62 deletions(-)
diff --git a/chapter08/gcc.xml b/chapter08/gcc.xml
index 9f3ba6c70..3b3d4e050 100644
--- a/chapter08/gcc.xml
+++ b/chapter08/gcc.xml
@@ -68,6 +68,7 @@ cd build</userinput></screen>
--enable-default-pie \
--enable-default-ssp \
--enable-host-pie \
+ --enable-targets=all \
--disable-multilib \
--disable-bootstrap \
--disable-fixincludes \
@@ -134,6 +135,16 @@ cd build</userinput></screen>
the Zlib library, rather than its own internal copy.</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><parameter>--enable-targets=all/</parameter></term>
+ <listitem>
+ <para>This switch tells GCC to enable 64-bit code generation
+ support even if we are building it for a 32-bit system.
+ It's needed to build GRUB for 64-bit UEFI. This switch has no
+ effect if building a 64-bit LFS.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
<note>
diff --git a/chapter08/grub.xml b/chapter08/grub.xml
index f4f99c8f8..cc1cc7afa 100644
--- a/chapter08/grub.xml
+++ b/chapter08/grub.xml
@@ -40,18 +40,6 @@
<sect2 role="installation">
<title>Installation of GRUB</title>
- <note>
- <para>
- If your system has UEFI support and you wish to boot LFS with UEFI,
- you need to install GRUB with UEFI support (and its dependencies) by
- following the instructions on
- <ulink url="&blfs-book;postlfs/grub-efi.html">the BLFS page</ulink>.
- You may skip this package, or install this package and the BLFS
- GRUB for UEFI package without conflict (the BLFS page provides
- instructions for both cases).
- </para>
- </note>
-
<warning>
<para>Unset any environment variables which may affect the build:</para>
@@ -103,8 +91,61 @@
<screen><userinput remap="install">make install</userinput></screen>
- <para>Making your LFS system bootable with GRUB will be discussed in
- <xref linkend="ch-bootable-grub" role='.'/></para>
+ <para>There are following sections that allow you to install support for
+ UEFI. After you have installed that support, if at all, making your LFS
+ system bootable with GRUB will be discussed in
+ <xref linkend="ch-bootable-grub" role='.'/></para>
+
+ <para>There are still more packages that need to be installed before the
+ system can become bootable.</para>
+
+ </sect2>
+
+ <sect2 role="installation">
+ <title>Installation of GRUB for 64-bit UEFI</title>
+
+ <para>If you want to boot with 64-bit UEFI, build the package again to
+ include support for it:</para>
+
+<screen><userinput remap="configure">make clean
+./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --target=x86_64 \
+ --with-platform=efi \
+ --disable-efiemu \
+ --disable-werror</userinput></screen>
+
+ <para>Compile the package again:</para>
+
+<screen><userinput remap="make">make</userinput></screen>
+
+ <para>Install support for 64-bit UEFI:</para>
+
+<screen><userinput remap="install">make -C grub-core install</userinput></screen>
+
+ </sect2>
+
+ <sect2 role="installation">
+ <title>Installation of GRUB for 32-bit UEFI</title>
+
+ <para>If you need support for 32-bit UEFI, which is very rare, then once
+ again build the package to include that support:</para>
+
+<screen><userinput remap="configure">make clean
+./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --target=i386 \
+ --with-platform=efi \
+ --disable-efiemu \
+ --disable-werror</userinput></screen>
+
+ <para>Compile the package again:</para>
+
+<screen><userinput remap="make">make</userinput></screen>
+
+ <para>Install support for 32-bit UEFI:</para>
+
+<screen><userinput remap="install">make -C grub-core install</userinput></screen>
</sect2>
diff --git a/chapter10/grub.xml b/chapter10/grub.xml
index 00be1d6c0..4b1b78074 100644
--- a/chapter10/grub.xml
+++ b/chapter10/grub.xml
@@ -16,17 +16,6 @@
<title>Using GRUB to Set Up the Boot Process</title>
- <note>
- <para>
- If your system has UEFI support and you wish to boot LFS with UEFI,
- you should skip the instructions in this page but still learn the
- syntax of <filename>grub.cfg</filename> and the method to specify
- a partition in the file from this page, and configure GRUB with UEFI
- support using the instructions provided in
- <ulink url="&blfs-book;postlfs/grub-setup.html">the BLFS page</ulink>.
- </para>
- </note>
-
<sect2>
<title>Introduction</title>
@@ -73,16 +62,35 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
<sect2>
<title>Setting Up the Configuration</title>
- <para>GRUB works by writing data to the first physical track of the
- hard disk. This area is not part of any file system. The programs
- there access GRUB modules in the boot partition. The default location
- is /boot/grub/.</para>
+ <para>If booting the system via BIOS, GRUB works by writing a stub to
+ the first sector (named the Master Boot Record, or MBR) of the hard
+ disk. This area is not part of any file system. The BIOS loads and
+ executes the content of MBR, then the stub loads the main GRUB image from
+ the BIOS Boot Partition. The GRUB image is stored as raw data instead
+ of a file (there must be no file system on the BIOS Boot Partition), so
+ the stub doesn't need to support any file system and it can be made small
+ enough to fit in the MBR.</para>
+
+ <para>If booting the system via UEFI, GRUB works by storing the main
+ GRUB image as a PE-COFF executable file at a standard location in the
+ EFI System Partition. The EFI firmware loads the file at the standard
+ location and executes it.</para>
+
+ <para>Many GRUB functions (including booting the Linux kernel) are
+ not included in the main GRUB image. Instead, they are stored in a file
+ system as GRUB modules. That file system is usually mounted in a
+ way that the GRUB modules can be accessed in
+ <filename class='directory'>/boot/grub</filename> on most Linux
+ distributions. To avoid the chicken-and-egg problem,
+ <command>grub-install</command> embeds the modules necessary to
+ access this file system into the main GRUB image, so it can find
+ and load other modules.</para>
<para>The location of the boot partition is a choice of the user that
affects the configuration. One recommendation is to have a separate small
- (suggested size is 200 MB) partition just for boot information. That way
- each build, whether LFS or some commercial distro, can access the same boot
- files and access can be made from any booted system. If you choose to do
+ (suggested size is 200 MB) partition just for boot information. That way
+ for each build, whether it's LFS or a commercial distro, it can access the
+ same boot files and can access can any booted system. If you choose to do
this, you will need to mount the separate partition, move all files in the
current <filename class="directory">/boot</filename> directory (e.g. the
Linux kernel you just built in the previous section) to the new partition.
@@ -100,25 +108,79 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
(or separate boot) partition is <filename
class="partition">sda2</filename>.</para>
- <para>Install the GRUB files into <filename
- class="directory">/boot/grub</filename> and set up the boot track:</para>
-
- <warning>
- <para>The following command will overwrite the current boot loader. Do not
- run the command if this is not desired, for example, if using a third party
- boot manager to manage the Master Boot Record (MBR).</para>
- </warning>
-
-<screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen>
+ <para>
+ The following sections go over how to boot with BIOS and UEFI.
+ The GRUB installations for BIOS, 64-bit UEFI, and 32-bit UEFI can
+ coexist and share the same configuration. So you can create both
+ the BIOS Boot Partition and the EFI System Partition, and install
+ GRUB for all the supported firmware types (i.e. running three
+ <command>grub-install</command> commands). If you are unsure about
+ your firmware type, or you plan to move the hard drive to a different
+ computer, this is something you can do as a blanket strategy.
+ </para>
- <note>
- <para>If the system has been booted using UEFI,
- <command>grub-install</command> will try to install files for the
- <emphasis>x86_64-efi</emphasis> target, but those files
- have not been installed in <xref linkend="chapter-building-system"/>.
- If this is the case, add <option>--target i386-pc</option> to the
- command above.</para>
- </note>
+ <sect3>
+ <title>Booting With BIOS</title>
+
+ <para>For booting with BIOS, make sure the boot partition is mounted
+ (if using a separate one) and the BIOS Boot partition exists. After that,
+ install the GRUB files into <filename
+ class="directory">/boot/grub</filename> and set up the boot track:</para>
+
+ <warning>
+ <para>The following command will overwrite the current boot loader. Do
+ not run the command if this is not desired, for example, if using a
+ third party boot manager to manage the MBR.</para>
+ </warning>
+
+<screen role="nodump"><userinput>grub-install /dev/sda --target=i386-pc</userinput></screen>
+
+ </sect3>
+
+ <sect3>
+ <title>Booting With UEFI</title>
+
+ <para>For booting with UEFI, make sure the boot partition is mounted
+ (if using a separate one) and the EFI System Partition is mounted at
+ <filename class='directory'>/boot/efi</filename>. After that, install the
+ GRUB files into <filename class="directory">/boot/grub</filename> and the
+ main GRUB image at
+ <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename>:</para>
+
+ <warning>
+ <para>The following command will overwrite the
+ <filename>/boot/efi/EFI/BOOT/BOOTX64.EFI</filename> file.
+ If it already exists, it's likely that it's the entry of another boot
+ loader (for example the GRUB installation from the host distro, or the
+ Windows Boot Manager). Backup the file so it can be restored later,
+ or loaded as a secondary boot loader by the new GRUB installation
+ from LFS.</para>
+ </warning>
+
+<screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable</userinput></screen>
+
+ <para>
+ The command above assumes that you have 64-bit UEFI firmware.
+ If you want to make the system bootable on 32-bit UEFI firmware,
+ run the command with <literal>x86_64-efi</literal> replaced by
+ <literal>i386-efi</literal>.
+ </para>
+
+ <para>
+ The <parameter>--removable</parameter> option makes
+ <command>grub-install</command> use the standard location,
+ <filename>EFI/BOOT/BOOTX64.EFI</filename> (or
+ <filename>EFI/BOOT/BOOTIA32.EFI</filename> for
+ <literal>i386-efi</literal>), instead of the location GRUB prefers
+ (<filename>EFI/GRUB/GRUBX64.EFI</filename> or
+ <filename>EFI/GRUB/GRUBIA32.EFI</filename>). Using a non-standard
+ location would result in the location in a EFI variable be recorded,
+ but LFS lacks the BLFS package <ulink
+ url="&blfs-book;postlfs/efibootmgr.html">efibootmgr</ulink>, which is
+ needed to manipulate EFI variables.
+ </para>
+
+ </sect3>
</sect2>
@@ -134,30 +196,40 @@ set timeout=5
insmod part_gpt
insmod ext2
+
set root=(hd0,2)
+
+# For UEFI
+insmod efi_gop
+insmod efi_uga
+
set gfxpayload=1024x768x32
menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" {
linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro
}</literal>
EOF</userinput></screen>
+<!-- GOP is probably not needed anyhow, since we're not using terminal_output
+ gfxterm. -->
<para>
The <command>insmod</command> commands load the
<application>GRUB</application> modules named
- <filename>part_gpt</filename> and <filename>ext2</filename>.
+ <filename>part_gpt</filename>, <filename>ext2</filename>,
+ <filename>efi_gop</filename>, and
+ <filename>efi_uga</filename>.
Despite the naming, <filename>ext2</filename> actually supports
<systemitem class='filesystem'>ext2</systemitem>,
<systemitem class='filesystem'>ext3</systemitem>, and
<systemitem class='filesystem'>ext4</systemitem> filesystems.
- The <command>grub-install</command> command has embedded some modules
- into the main <application>GRUB</application> image (installed into
- the MBR or the GRUB BIOS partition) to access the other modules
- (in <filename class='directory'>/boot/grub/i386-pc</filename>) without
- a chicken-or-egg issue, so with a typical configuration these two
- modules are already embedded and those two <command>insmod</command>
- commands will do nothing. But they do no harm anyway, and they may
- be needed with some rare configurations.
+ On UEFI systems, <filename>efi_gop</filename> and
+ <filename>efi_uga</filename> are for video support. GOP, or Graphics
+ Output Protocol, is the modern approach. UGA, or UGA Draw Protocol, is
+ a legacy way of handling it.
+ In a typical configuration, these four modules are already embedded in
+ the main GRUB image by <command>grub-install</command>, and those four
+ <command>insmod</command> commands will do nothing; However, they do no
+ harm anyway, and they may be needed with some rare configurations.
</para>
<para>
@@ -165,7 +237,8 @@ EOF</userinput></screen>
resolution and color depth of the VESA framebuffer to be passed to the
kernel. It's necessary for the kernel SimpleDRM driver to use the
VESA framebuffer. You can use a different resolution or color depth
- value which better suits for your monitor.
+ value which better suits for your monitor. This line does nothing
+ when the system is booted via UEFI, but it does no harm anyway.
</para>
<note><para>From <application>GRUB</application>'s perspective, the
@@ -219,8 +292,9 @@ EOF</userinput></screen>
can write a configuration file automatically. It uses a set of scripts in
/etc/grub.d/ and will destroy any customizations that you make. These scripts
are designed primarily for non-source distributions and are not recommended for
- LFS. If you install a commercial Linux distribution, there is a good chance
- that this program will be run. Be sure to back up your grub.cfg file.</para></caution>
+ LFS. If you install a commercial Linux distribution, there is a good chance
+ that this program will be run. Be sure to back up your grub.cfg
+ file.</para></caution>
</sect2>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
--
http://lists.linuxfromscratch.org/sympa/info/lfs-book
Unsubscribe: See the above information page