Building a Custom Kernel In Linux

You may like to use a kernel apart from one provided by your distro. Below are the steps which guide you through the entire configuration, compilation and installation of custom linux kernel

1. Open the terminal in linux and type #sudo su to gain administrator privileges.

2. Before you begin with the addition of the custom kernel, you should make sure that you have installed ncurses-dev library in your system.

ncurses (new curses) is a programming library that provides an API which allows the programmer to write text-based user interfaces in a terminal-independent manner. It is a toolkit for developing “GUI-like” application software that runs under a terminal emulator. It also optimizes screen changes, in order to reduce the latency experienced when using remote shells.

Just type the command apt-get install ncurses-dev to install ncurses-dev library in your system

3. Type #/cd/usr/src and press the Enter key.

4 .Now type #wget (link of the kernel source you want to add).

In my case, I want to add the latest stable kernel so I have used #wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.0.1.tar.xz. You can go the link https://www.kernel.org/ to download the kernel source you wish.

5. Once you have downloaded the kernel you want, it’s time to extract the kernel source.

Type the following command on the terminal #untar (download file name).

In my case it’s untar linux-4.0.1.tar.xz.

6. Now enter the source directory of the linux kernel you’ve just downloaded.

In my case I shall type #cd linux-4.0.1.tar.xz

7. Now once you’ve entered this directory, it’s time to compile the kernel source you want to add.

Type #make and then press the enter key. This process will take almost half an hour, depending on the clock speed of your pc. You need to be patient at this stage.

8. Now once you have compiled the linux kernel source, it’s time for make menuconfig, used to configure the linux kernel source. Just type on the terminal #makes menuconfig and exit saving default values. This will generate a .config file which will be later used as the default configuration of the linux kernel.

9. After configuring the linux kernel successfully, it’s time to compile and install all the modules associated with this kernel source. For that you need to type #make modules_install install. This would take 5-10 minutes.

10. Now you need to reboot your system using #reboot command. Once your system restarts, and linux kernel boots, go to the advanced optios in the menu displayed. You will get a new option in the list of linux kernels installed. Select the linux kernel you want, it will be ready right as the rain.

You can check the new version of kernel by typing #uname -rcommand in the terminal. You will get the version of the kernel you are currently working on.

Now even if you don’t want to install custom kernel, Steps 6-10 can be followed to fix all driver issues related to your system. This includes usb, net connectivity and a lot of other problems which can be fixed by just strictly following steps 6-10.

This content has been helpful to you?

Thanks for contributing!

Yes No