Compilation And Installation Of Kernel In Linux

Today, we will talk about and learn how to install and compile the kernel code of Linux using a virtual box. Actually, Linux is an open source operating system and we can easily modify and customize its kernel code for many reasons. Sometimes, we may want a machine that is very fast and its kernel is so light. So, in this situation, we have to customize and modify the kernel code.

Note: It is suggested to try this on a virtual machine first so as to avoid any trouble.
 
Now, let’s start. I have a virtual box if you have a VM ware or virtual box, just make yourself one Linux machine. After this, it should look like this.

Step 1

Compile And Installation Of Kernel In Linux 

Step 2

Start the terminal.

Compile And Installation Of Kernel In Linux 

Step 3

Here, you are ready to install the new kernel. Just run the below command on your terminal.

wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.gz
tar zxvf linux-2.4.19.tar.gz
cd linux-2.4.19

The kernel originates as a 20 to 30 MB tar.gz or tar.bz2 file. It will decompress to nearly 200 MB and throughout the later compilation, you will need extra space. After executing this above command, the screen should be like this. The download from its website takes some time.

Compile And Installation Of Kernel In Linux 

Step 4

After completion, it decompresses automatically and looks like this.
 
Compile And Installation Of Kernel In Linux 

Step 5

After that, you have some options about configuration. If you want to install default modules, run just the make command otherwise you have other config options.
 
Compile And Installation Of Kernel In Linux 

Step 6

After this, we have to install modules by executing the following command.

$ sudo make modules_install

The screen will look like below.

Compile And Installation Of Kernel In Linux 

Step 7

At this stage, we have compiled the Linux Kernel and installed kernel modules. Now, it is time to install the kernel itself by executing this command.

$ sudo make install

Step 8

After this, the following commands are noncompulsory because the "make install" command does everything for your but I have included these here for tradition only.
 
$ sudo update-initramfs -c -k 4.20.12
$ sudo update-grub

Step 9

Now, you have to shut down or reboot your machine by the following command.

# reboot

After rebooting, let us verify our latest kernel by executing this command.

$uname –mrs
Compile And Installation Of Kernel In Linux 

Congratulations, we have downloaded, compiled, and installed kernel code.


Similar Articles