How to built and install Linux kernel in Ubuntu

Today we will see how to built and install Linux kernel in ubuntu(I hope it works for all Debian distros).

I’m using Ubuntu 14. First things first, install required packages in order to built kernel


sudo apt-get update
sudo apt-get upgrade

sudo apt-get install kernel-package
sudo apt-get build-dep linux-image-$(uname -r)
sudo apt-get install ecere-dev
sudo apt-get install libncurses5 libncurses5-dev


Download  the Linux Kernel from



Create a directory call it as “kernel” in your home(or wherever you want!), in my case /home/veerendra/kernel/. Copy the downloaded .tar to current directory (/home/veerendra/kernel/) and extract the linux-4.5.1.tar.xz to current directory.

tar -xvf linux-4.5.1.tar.xz .



If you want, you can explore the linux-4.5.1 directory which have the kernel source code. In order to build the kernel, you need to configure. The Linux Kernel support almost all hardwares and provides “lot” of options. So, we need to instruct what modules to be installed. For starters like me, you can copy the “config” from “/boot/”.  Copy config from “/boot” to ./linux-4.5.1 (In my case, /home/veerendra/kernel/linux-4.5.1). We are copying it as “.config” file (Hidden file). To view that file run –> “ls -lart”


Note: I copied “config-3.13.0-85-generic”. In your system it is different, so pick file starts with “config”.


In config file, you can specify what to install. If you enable a feature, that will include in the built. And there is another option “M” means Module i.e. load it as module, whenever you need (For example bluetooth, when you plug-in the bluetooth device, the OS loads the appropriate program). So, in order to set/unset these option, open .config with gedit and yes/no the options (but, there are 7000 options!!). Luckily we have some GUI tools like “menuconfig”. Go to “linux-4.5.1” (/home/veerendra/linux-4.5.1) and type

make menuconfig


If everything is ok (if required packages has already installed), it will show up screen like below.


“*” means, it is enabled. If your machine is 32-Bit, remove “*” . You can explore all other options. (“–>” indicates there are some other options that you can configure)


Save the configuration, when you are done!


Start compiling! by running below command

sudo make-kpkg -j 5 –initrd kernel-image kernel-headers

I mentioned the number “5” in above command, which means number of jobs. Kernel building process will take some time and CPU. If you want the kernel building fast, increase the number of jobs. Some people would say, if you have 4 core then the jobs will be 4+1 or double the number of core. I ran with 5 jobs, took 3 hour for building. (You can check the time in screenshot :-P)



Finally the compiling is completed(After 3 Hr.). As you can see in below screenshot, it is generated debian packet. That’s what we want!

The .deb package is in /home/veerendra/kernel



We compiled the Kernel as .deb package, while installing .dep package, it will take care of adding the new kernel image to GRUB File

This is one of the advantage, if you compile the kernel as .dep package. Now install the deb package

sudo dpkg -i <package>.deb



Now restart the machine

sudo init 6

After the restart, open terminal and type

uname -a


If everything is good, you are able to see like above. 🙂




3 thoughts on “How to built and install Linux kernel in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s