Quick guide to be able to compile any Linux Kernel

Quick guide to be able to compile any Linux Kernel

Quick guide to be able to compile any Linux Kernel

A few days ago this month December 2022, versions of the Linux kernels 6.1-rc8 (mainline),  6.0.11 (stable) and 5.15.81 (LongTerm).

For this reason, we offer you this new little quick guide to successfully achieve "compile a linux kernel", in any version of GNU / Linux Distro, basic Debian, Ubuntu and Mint, anytime.

Linux

And, before starting this post related to the possibility of "compile a linux kernel"We invite you to explore the following related contents, at the end of today's:

Linux
Related article:
How to install Linux Kernel 5.5 in Ubuntu and derivatives?
Linux 5.1 official
Related article:
How to install Linux Kernel 5.1 in Ubuntu and derivatives?

Compiling a Linux Kernel on Debian, Ubuntu and Mint

Compiling a Linux Kernel on Debian, Ubuntu and Mint

Steps to successfully compile a Linux Kernel

Installing Essential Packages (Development Support)

apt install autoconf automake autotools-dev build-essential dh-make debhelper debmake devscripts dpkg fakeroot file gfortran git gnupg fp-compiler lintian patch pbuilder perl python quilt xutils-dev

Choose the desired version

To do this, we must go to Official website of the kernels, and choose one among the existing categories. and copy the download path available from the chosen kernel from its respective tarball button, and then continue with the following steps. Whereas, for our example today, we will continue the following steps using the Stable Linux kernel version 6.0.11:

Stage 1
cd /usr/src
wget -c https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.0.11.tar.xz
sudo unxz linux-6.0.11.tar.xz
sudo tar xvf linux-6.0.11.tar
sudo ln -s linux-6.0.11 linux
cd /usr/src/linux
sudo make clean && make mrproper
sudo cp /boot/config-`uname -r`* .config
make menuconfig

At this point, the "Kernel configuration menu", where we can configure (customize) parameters of the Kernel of our preference or need. Keep in mind that, at this point, it is essential check or uncheck the 64-bit kernel option, depending on what we want or require. And also, after having made all the changes made, we must press the Save button And then the Exit button.

Kernel configuration menu

Stage 2

Arrived here, they remain 2 possible ways to choose:

Kernel installation only

sudo make
sudo make modules_install
sudo make install
sudo update-grub; sudo update-grub2; sudo update-initramfs -u
sudo apt clean; sudo apt autoclean; sudo apt autoremove; sudo apt remove; sudo apt purge

Yes, everything runs and ends well, to finish we just have to restart our computer and test that it already loads our operating system with the new kernel compiled.

The installation of the Kernel and the creation of the .deb files of the created Kernel

To execute this step, it is relevant to have the installation of the package called kernel-package. For this reason, and in the event that the GNU/Linux Distro used does not have it in its repositories, the following auxiliary procedure can be executed:

sudo wget -c http://ftp.us.debian.org/debian/pool/main/k/kernel-package/kernel-package_13.018+nmu1~bpo9+1_all.deb
sudo apt install ./kernel-package_13.018+nmu1~bpo9+1_all.deb

Having installed this package, we can now continue with the following steps:

fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
cd /usr/src
sudo dpkg -i *.deb

And in case, during the compilation process, an error occurs error related to kernel certificates, we can execute the following command order to fix it automatically, and try again:

sed -i '/CONFIG_SYSTEM_TRUSTED_KEYS/s/^/#/g' .config

Yes, everything runs and ends well, to finish we just have to restart our computer and test that it already loads our operating system with the new kernel compiled.

How to compile Kernel 2.6.36.2 in Ubuntu with the 200-line patch included
Related article:
How to compile Kernel 2.6.36.2 in Ubuntu with the 200-line patch

Abstract banner for post

Summary

In short, we hope that anyone with this little Fast guide I can easily and successfully achieve "compile a linux kernel" on a Distro Debian, Ubuntu and Mint, or derivative.

If you liked the content, comment and share it. And remember, visit the beginning of our «site», in addition to the official channel of Telegram for more news, tutorials and Linux updates. West group, for more information on today's topic or other related ones.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.