Foenix index



Linux Kernel Build


// Setting

These steps were developed on Debian Linux. Most of the steps will work on
other linux distributions, but you will need to use other commands to install
development tools on some distributions.


// Use of the root user

Unix/linux convention recommends against use of the root user as a general
purpose account. For example, it is a bad habit to do development work as
root.

Building and installing a new kernel is one of the few tasks that does justify
use of the root user.

Some of the steps must be done as root, and it is most secure to do all steps
as root.


// Linux Kernel Build

In a terminal window, become the root user.
    # sudo su -

Make sure you have development tools installed. This list might not be
exhaustive, further tweaks welcome.
    # apt install bin-tools gcc make

You should be logged into your workstation as your normal user. In
your web browser, navigate to kernel.org.

In your root window, download the tarball for the latest release root homedir
    # cd /root
    # curl -O 'https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.12.tar.xz'

Unpack the archive to ~root
    # cd /root
    # tar zxvf linux-5.15.12.tar.xz

Copy a kernel config file in from an existing boot image.
    # cd linux-5.15.12
    # cp -p /boot/config-4.19.0-13-amd64 .config

Upgrade that old config file format to the version expected by the kernel you
are building,
    # make olddefconfig

Edit your .config to ensure that CONFIG_SYSTEM_TRUSTED_KEYS is empty.

Build and install the kernel,
    # time make -j $(nproc)
    # make INSTALL_MOD_STRIP=1 modules_install
    # make INSTALL_MOD_STRIP=1 install
    # update-grub