Linux Ubuntu 22.04

How To Compile And Install Kernel On Ubuntu [2022]

How To Compile And Install Kernel On Ubuntu
Written by itsubuntu

Steps To Compile And Install Kernel On Ubuntu

Linux Kernel is the backbone of the Linux-based operating system. No matter which Linux you are using, Linux Kernel will be the same and will remain the crucial section of your operating systems. Linux Kernel is the heart of the operating system.

Before installing or updating Kernel, you have to make sure that you have a backup of the system and other important files so that you can restore it in case of any emergency.

How To Compile And Install Kernel On Ubuntu

In this article, We will install and compile the kernel on Ubuntu.

At first, you need to download the Linux kernel from the website of  Linux Kernel Organization, Inc.

Download Linux Kernel

At the time of this article writing, Linux Kernel 5.16.13 is the latest version of Linux Kernel. Meanwhile, you can also download the Linux kernel from the command line.

sudo wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.16.13.tar.xz

Now, you need to install the requirements or dependencies before compiling and installing Linux Kernel on Ubuntu.

sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bcflex libelf-dev bison

Now, run the following command for extracting the downloaded file.

sudo tar xvf linux-5.16.13.tar.xz

Now, you need to move to the directory that is recently created while extracting the file.

cd linux-5.16.13

Let us now configure our Kernel :

cp/boot/config-$(uname -r) .config

Now, execute the make menuconfig command so that you can have access to a configuration tool

make menuconfig

Now, you will see the various module in the configuration tool window. From this window, you can disable or enable the various modules.

Compiling Kernel On Ubuntu

The first part will be compiling the kernel with the make command and the second part will be installing the kernel modules.

sudo make

Run the following command to know the number of cores available

sudo nproc

Now, you can mention the core with the make command

sudo make-j<3

The -j option is used to assign more cores to the process so that the process speeds up.

Now, here we need to install all the modules that you enabled on the configuration tool for:

 make modules_install

Install Kernel On Ubuntu

Now, it’s time to install Linux Kernel On Ubuntu.

 sudo make install

Once you are done with installing Kernel, run the following command to enable Kernel for a boot.

 sudo update-initramfs -c -k 5.16.13

Now update-grub

sudo update-grub

Now, reboot your Linux (Ubuntu)

sudo reboot

After restarting your Ubuntu, you can run the following command to verify the new Linux Kernel version:

sudo uname -mrs

Summary:

This post teaches you the method for compiling and installing Linux Kernel on Ubuntu. Let us know if you have suggestions for this article in the comment box below. Share our post on “How To Compile And Install Kernel On Ubuntu” to your community and help us to grow.

About the author

itsubuntu

Leave a Comment