Creating a .config File
The first step to compile the kernel is to create a .config file in which the functions and features that need to be enabled are declared.
- Install the dependencies for compiling the kernel.
1 2 3 4 5 6
# sudo apt install -y build-essential # sudo apt install -y libncurses5-dev openssl libssl-dev # sudo apt install -y pkg-config # sudo apt install -y bison # sudo apt install -y flex # sudo apt install -y libelf-dev
- Copy the config file in the /boot directory to the source code directory and rename the file to .config.
In the preceding command, the name of the configuration file in the /boot directory is only an example. Run the uname -r command to view the actual file name. The .config file version must match the OS kernel version.
1# cp /boot/config-`uname -r` /usr/src/linux-kernel-5.15.98/.config - Create a .config file.
1 2
# cd /usr/src/linux-kernel-5.15.98/ # sudo make menuconfig
- Click Load in the following window:

- Click OK in the following window:

- Click Save in the following window:

- Click OK in the following window:

- Click Exit in the following window:

- Go to the initial window and click Exit. The .config file is created in the current folder.

Parent topic: Compiling and Installing the Kernel