How To Compile Linux Kernel From Source Code? – POFTUT

How To Compile Linux Kernel From Source Code?

Hi, today we are going to compile Linux kernel. you can think that compiling kernel is very complicated and hard for you. But it is not. It is more easy to compile than a lot of other projects. Because Linux kernel has no dependency to a library or other tools. It needs just ncurses development library which is used for module configuration.

Download Linux Kernel Source Code

Linux Kernel is an open-source project which is can be used anyone without any fee and freely. Linux Kernel source code is provided by http://www.kernel.org . First we will download the latest mainline kernel source code.

Download Linux Kernel Source Code

Download Linux Kernel Source Code

Extract Linux Kernel

Then decompress it. The postfix of file like xz, gz is not important they are just different compression algorithms all ingredients are the same

Enter the decompress directory

Install Dependencies

Run module configuration menu for the kernel. Here you need ncurses devel library for C programming language.

Ubuntu, Debian, Mint, Kali

Fedora, CentOS, RedHat

Kernel Build Configuration

We will run the kernel configuration tool with the following command.

You can configure the file system module from here. If you have space constraint you can remove unneeded file system modules or add required file system modules

Kernel Build Configuration

Kernel Build Configuration

Here are driver modules. As I said above you can remove unneeded modules or add drivers you need.

Kernel Driver

Kernel Driver

Virtualization modules can be configured with this menu. Say you have AMD CPU you do not have to compile Intel drivers.

Kernel Virtualization

Kernel Virtualization

After applying all settings you can save them and exit

Save Kernel Compile Configuration

Save Kernel Compile Configuration

Kernel Config

Kernel Config

Make Help

Now we are ready to compile process. There is a lot of compile options but I am gonna show you some of them. If you want to see all off them run make help

LEARN MORE  Linux vs Unix

Make Help

Make Help

Compiling Linux Kernel As ISO Image

We can compile the Linux Kernel with the isoimage option which will make ISO files to boot the kernel. This ISO can be burned into a CD too.

After compilation, you can find your image in arch/x86/boot/image.iso

Compile Linux As Binary

Linux kernel can be compiled with the make command. By providing the -j8 compilation will be done in a multi-threat way.

Compile Linux As Binary

Compile Linux As Binary

Install Linux Kernel

We can install compiled Linux kernel like below. This will change the current kernel of the Linux distribution and boot next time with this kernel.

1 Response

  1. 09/10/2019

    […] also USB interfaces exists. Tcpdump can listen USB protocol from USB interfaces and other special Kernel devices. Tcpdump numbers interfaces as optionally usage. First to select interface list interfaces […]

Leave a Reply

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

Enjoy this blog? Please spread the word :)