6.21. Linux-5.15.0-rc5

The Linux package contains the Linux kernel.

Approximate build time: 1.5 SBU
Required disk space: 1200 MB

6.21.1. Installation of the 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=loongarch CROSS_COMPILE=$LFS_TGT- menuconfig

The meaning of optional make environment variables:

ARCH=loongarch

Configure the kernel for running on the target machine.

CROSS_COMPILE=$LFS_TGT-

Build the kernel with Binutils and GCC built in Chapter 5.

menuconfig

This launches an ncurses menu-driven interface. For other (graphical) interfaces, type make help.

(optional) 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.

[Note]

Note

A good starting place for setting up the kernel configuration is to run make ARCH=loongarch CROSS_COMPILE=$LFS_TGT- defconfig. This will set the base configuration to a good state that takes your target system architecture into account.

You should now enable/disable/set some options as the introduction in Section 10.3, “Linux-5.15.0-rc5”. And then you should enable or disable some kernel configuration options suitable for a temporary kernel image:

Kernel configuration options and explanation:

Disable CONFIG_MODULES

Modular kernel needs modprobe tool from Kmod to load modules, which is not installed in the temporary system.

Set CONFIG_EXTRA_FIRMWARE="a.bin b.bin"

Build firmware blobs into the kernel. Some drivers may require it if they are not built as module.

[Note]

Note

The kernel images with third-party blobs are not distributable. If you distribute it to others, you may violate GPL. It's recommended to remove it after you've successfully boot your LFS system with the new kernel image, which would be installed in Section 10.3, “Linux-5.15.0-rc5”.

Set 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-5.15.0-rc5” can load them without CONFIG_EXTRA_FIRMWARE.

Enable CONFIG_EXT2, CONFIG_EXT4, and CONFIG_VFAT_FS

They are needed to access the filesystems we'll make for the target system.

Enable CONFIG_BLK_DEV_INITRD

It will be needed for ACPI-Update package.

Compile the kernel image and modules:

make ARCH=loongarch CROSS_COMPILE=$LFS_TGT-

Install the kernel image into the $LFS/boot directory:

install -vm644 vmlinux $LFS/boot

Details on this package are located in Section 10.3.3, “Contents of Linux.”