Linux Kernel Compilation (Kernel version 3.x)

The first step! If you want to learn Linux kernel programming, don’t just read on all those nice books. You have to start doing also. Lets see how to get your own working kernel on that machine. Caution: use this article in your own risk, and take backup of all critical data before you start. I will not covering all the possible steps in compiling the kernel, just demonstrating the minimal steps required to get the kernel fast.

My setup : Dell Inspiron 3521 with FC 18  i686 (Fedora) operating system. Kernel version used for this article linux-3.16.1

You can use dmidecode or /sys/class/dmi/id/product_name to get the system name

[root@localhost ~]# dmidecode |grep Product
Product Name: Inspiron 3521
[root@localhost ~]# cat /sys/class/dmi/id/product_name
Inspiron 3521

Download Linux Kernel

First, get the complete mighty Linux kernel source in your system. go to and download the latest stable kernel version (I am using linux-3.16.1 for this article)


Once downloaded the kernel, untar it (as below) and you will have kernel source extracted

tar -Jxvf linux-3.16.1.tar.xz

Compiling the kernel

Change to extracted kernel folder before proceeding further.

The .config file should be available to start the kernel compilation. the .config file will contains configuration entries for kernel. To start fresh you can use make menuconfig which will give a graphical configuration utility or make config (use make help to get more options) but to make things easy at the beginning we will use:

[root@localhost linux-3.16.1]# make defconfig
*** Default configuration is based on ‘i386_defconfig’
# configuration written to .config

This will generate a .config file using pre defined values for configuration. The values used are generically used hence may change (rarely) with setup. But this is simplest and won’t trouble us with lots of options :-)

Lets do one more minor tweak here and add a local version to kernel to make it look more customized.

[root@localhost linux-3.16.1]# make menuconfig

you will get the console based UI for editing options


Select General Setup –> ‘Local version – append to kernel release’

type your name there the finial kernel will be 3.16.1yourname after build.

Now, Lets start the compile the kernel using ‘make‘ command

root@localhost linux-3.16.1]# make -j4

The make command builds the kernel binary and modules (drivers and related stuff). The -j options is to make the compilation multi-threaded. The number ex: -j4 is given best according to the number of processor, i.e -j<number of processors> * 2

The compilation process will take some time. Sit back and relax :-). Once the compilation is done. You have to install the kernel to boot from it next time. To put the kernel binary files in appropriate location in your filesystem, do the following

[root@localhost linux-3.16.1]# make modules_install
[root@localhost linux-3.16.1]# make install

These commands will copy the modules and vmlinuz, the kernel binary to appropriate locations and update the boot loader (GRUB) configuration with newly compiled kernel information.

Done! now reboot your machine and you can boot from the newly compiled kernel.


Please comment below your suggestions and let me know about corrections in this article.


One comment

Leave a Reply

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

one + eleven =