Details on this package are located in Section 10.3.3, “Contents of Linux.”
The Linux package contains the Linux kernel.
Building the kernel involves a few steps—configuration,
compilation, and installation. Read the README
file in the kernel source tree for
alternative methods to the way this book configures the kernel.
Prepare for compilation by running the following command:
make mrproper
This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.
There are several ways to configure the kernel options. Usually, This is done through a menu-driven interface, for example:
make ARCH=x86
CROSS_COMPILE=$LFS_TGT- menuconfig
The meaning of make environment variables:
Configure the kernel for running on the target machine.
Replace x86
with a
value suitable for your target machine if it's not a 32-bit
or 64-bit x86.
Build the kernel with Binutils and GCC built in Chapter 5.
This launches an ncurses menu-driven interface. For other (graphical) interfaces, type make help.
LANG=<host_LANG_value>
LC_ALL=
This establishes the locale setting to the one used on the host. This may be needed for a proper menuconfig ncurses interface line drawing on a UTF-8 linux text console.
If used, be sure to replace <host_LANG_value>
by
the value of the $LANG
variable
from your host. You can alternatively use instead the host's
value of $LC_ALL
or $LC_CTYPE
.
A good starting place for setting up the kernel configuration is to run make ARCH=x86 CROSS_COMPILE=$LFS_TGT- defconfig. This will set the base configuration to a good state that takes your target system architecture into account.
Read Section 10.3, “Linux-6.10.5” for more information about kernel configuration. You should enable or disable some kernel configuration options now:
Kernel configuration options and explanation:
CONFIG_MODULES=n
Modular kernel needs modprobe tool from Kmod to load modules, which is not installed in the temporary system.
CONFIG_EXTRA_FIRMWARE="a.bin b.bin
"
Build firmware blobs into the kernel. Some drivers may require the firmwares to be in-kernel if the driver is not built as module.
The kernel binaries with third-party blobs are not distributable. If you distribute such a kernel binary to others, you may violate GPL. It's recommended to remove the temporary kernel image after you've successfully boot your LFS system with the new kernel image, which will be installed in Section 10.3, “Linux-6.10.5”.
CONFIG_EXTRA_FIRMWARE_DIR="$LFS
/lib/firmware"
The building system will search /lib/firmware
for firmware blobs in
CONFIG_EXTRA_FIRMWARE
. Note
that you'll need to install the needed firmwares into
$LFS/lib/firmware
first, and
manually replace $LFS
with the
value in configuration. The firmwares in $LFS/lib/filename
will be copied to the
target machine along with the system, so kernel and kernel
modules which will be built in Section 10.3,
“Linux-6.10.5” can load them without CONFIG_EXTRA_FIRMWARE
.
CONFIG_EXT2=y
, CONFIG_EXT4=y
, and CONFIG_VFAT_FS=y
They are needed to access the filesystems we'll make for the target system.
CONFIG_MODULE_SIG=n
, CONFIG_SECURITY=n
, CONFIG_STACK_VALIDATION=n
,
CONFIG_SYSTEM_TRUSTED_KEYRING=n
,
and CONFIG_SYSTEM_REVOCATION_LIST=n
They are unneeded for the temporary kernel, and they need additional dependencies which may be unavailable on the host distro. You can enable them building the kernel for the final LFS system in Chapter 10 if you need these features.
Compile the kernel image:
make ARCH=x86 CROSS_COMPILE=$LFS_TGT-
Install the kernel image into the $LFS/boot
directory:
install -vm644 arch/x86/boot/bzImage $LFS/boot/vmlinuz
Details on this package are located in Section 10.3.3, “Contents of Linux.”