7.9. Linux-4.9.21

The Linux package contains the Linux kernel.

7.9.1. Installation of the kernel

[Warning]

Warning

Here a temporary cross-compiled kernel will be built. When configuring it, select the minimal amount of options required to boot the target machine and build the final system. I.e., no support for sound, printers, etc. will be needed.

Also, try to avoid the use of modules if possible, and don't use the resulting kernel image for production systems.

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.

Apply the latest Linux sublevel patch:

xzcat ../patch-4.9.21.xz | patch -Np1 -i -

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.

[Note]

Note

A good starting place for setting up the kernel configuration is to run make defconfig. This will set the base configuration to a good state that takes your current system architecture into account.

Be sure to configure the following options as shown, or the system might not work correctly or boot at all:

Device Drivers  --->
  Generic Driver Options  --->
    ()  path to uevent helper (CONFIG_UEVENT_HELPER_PATH)
    [*] Maintain a devtmpfs filesystem to mount at /dev (CONFIG_DEVTMPFS)
    [ ] Fallback user-helper invocation for firmware loading (CONFIG_FW_LOADER_USER_HELPER)

Configure the kernel via a menu-driven interface:

make ARCH=i386 CROSS_COMPILE=${CLFS_TARGET}- menuconfig

Compile the kernel image and modules:

make ARCH=i386 CROSS_COMPILE=${CLFS_TARGET}-

If the use of kernel modules can't be avoided, a file in /etc/modprobe.d may be needed. Information pertaining to modules and kernel configuration is located in the kernel documentation in the Documentation directory of the kernel sources tree. The modprobe.d man page may also be of interest.

Install the modules, if the kernel configuration uses them:

make ARCH=i386 CROSS_COMPILE=${CLFS_TARGET}- \
    INSTALL_MOD_PATH=/tools modules_install

Install the firmware, if the kernel configuration uses them:

make ARCH=i386 CROSS_COMPILE=${CLFS_TARGET}- \
    INSTALL_MOD_PATH=/tools firmware_install

After kernel compilation is complete, additional steps are required to complete the installation. Some files need to be copied to the /tools/boot directory.

Issue the following commands to install the kernel:

mkdir -pv /tools/boot
cp -v arch/i386/boot/bzImage /tools/boot/vmlinuz-clfs-4.9.21

System.map is a symbol file for the kernel. It maps the function entry points of every function in the kernel API, as well as the addresses of the kernel data structures for the running kernel. Issue the following command to install the map file:

cp -v System.map /tools/boot/System.map-4.9.21

The kernel configuration file .config produced by the make menuconfig step above contains all the configuration selections for the kernel that was just compiled. It is a good idea to keep this file for future reference:

cp -v .config /tools/boot/config-4.9.21

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