Updating, compiling and installing the Linux Kernel from our previously cloned Linux repository

Updating, compiling and installing the Linux Kernel from our previously cloned Linux repository

Hi everyone,

In this post, I will show you how to update a locally cloned Linux Repo, run some cleanup commands, and compile the kernel again. We will then proceed to install it.

This post will be shorter than yesterday due to the fact that we have already performed the preparations to compile it. We will simply be running a git pull command to update our local repository with the latest remote repository changes, run some cleanup commands, and run the make command that will compile it.

Step 1: Updating our local Linux Kernel repository

First, we must update our local Linux Kernel repository with the latest remote repository changes. We will do this by navigating to our local repository folder:

Updating and Compiling the Linux Kernel - 01

Then, we will run git pull:

Updating and Compiling the Linux Kernel - 02

Our local repository will be updated with the latest remote repository changes:

Updating and Compiling the Linux Kernel - 03

At this point, we have successfully updated our local Linux Kernel repository with the latest remote repository changes.

Step 2: Cleaning up our environment

Before we can compile the Linux Kernel again, we must clean up our environment by removing the debian directory and the vmlinux-gdb.py files. Failing to do so will cause the make command to fail.

We will run these 2 lines inside the Linux repository folder:

rm -r debian
rm vmlinux-gdb.py
Updating and Compiling the Linux Kernel - 04

At this point, we have cleaned up our environment and are ready to compile the Linux Kernel again.

Step 3: Compiling the Linux Kernel

As we did yesterday, we will be using the make command:

 make -j $(getconf _NPROCESSORS_ONLN) deb-pkg LOCALVERSION=-daily-20221201

Note that I changed the LOCALVERSION variable to yesterday’s date (20221201).

Updating and Compiling the Linux Kernel - 05

The Linux Kernel will be compiled and packaged into new .deb files:

The new .deb files will be in the previous folder:

Updating and Compiling the Linux Kernel - 09

At this time, we have compiled the new Linux Kernel code.

Step 4: Installing the Linux Kernel

We will install the Linux Kernel with the dpkg command:

sudo dpkg -i linux*20221201*.deb

I’m using 2 wildcard characters there to only select the files having the word linux and the date string 20221201, as well as the .deb extension. We do not want to install the other .deb packages we may have there.

Updating and Compiling the Linux Kernel - 10

The installation should run normally and complete successfully:

Updating and Compiling the Linux Kernel - 11

Now, reboot your machine and confirm the new Linux Kernel is installed and running with uname -r:

Updating and Compiling the Linux Kernel - 12

And that’s it! You have successfully updated your local Linux Kernel repository, compiled it and installed it.