![](https://assets.isu.pub/document-structure/211012184157-d26059021e2bb894b5c34e587b6491a9/v1/ec873c9a32caea26873ec0cd3bd28ade.jpeg?width=720&quality=85%2C50)
3 minute read
A Simple Guide to Building Your Own Linux Kernel
from n Source ...ber 2012
by Hiba Dweib
This article is for all the newbies who want to learn how to build their own Linux kernel. Following the steps mentioned will demonstrate how easy the task is!
Please note that the steps mentioned were done on Ubuntu 10.04, but would remain the same for any Linux distribution.
Advertisement
Pre-requisites
Git is the utility for version control on Linux. Install it with a simple sudo apt-get install git-core. You also need the curses library development files—install the package with sudo aptget install libncurses5-dev.
Next, verify the current Linux kernel version with the uname –a command so you can download the relevant kernel source to build using the git clone command. I’ve used Linux 2.6 in this example, as you can see in Figure 1.
Configuring the kernel
Now that you have the source, you need to configure it. You can use the command make menuconfig if you are experienced on what configuration parameters to set. If you are new to this, I would suggest you use the default configuration—copy the existing config file to the kernel source directory with, for example, cp /boot/config/-2.6.32-38-generic .config
Now, run make oldconfig to start the configure process. Please note that here you will be prompted to answer ‘Yes’ or ‘No’. If you are unsure, just keep on hitting ‘Enter’ (that is a default ‘Yes’).
Naming the kernel
Next, it might be good to give your kernel a name. For this, open the Makefile, and edit the lines below:
VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 32 EXTRAVERSION = -dips NAME = Building My Kernel
Now, issue the make command. This should take a couple of hours to complete.
Installing the kernel
Now, issue the following command to install all the kernel modules:
make INSTALL_MOD_STRIP=1 modules_install
Next, run a make install.
Updating with initramfs
Run the command, sudo update-initramfs -c -k 2.6.32-dips+
For readers who are keen to know what initramfs is, it is a root filesystem that is loaded at an early stage of the boot process. It is the successor of the old initrd.
Verify the installation
Now, we are almost done! To verify, check your /boot directory. Are you able to find the new kernel image and the config file for your build? If yes, then congratulations! You have succeeded in building your kernel.
Modify the GRUB file and reboot
GRUB stands for Grand Unified Bootloader. It is a bootloader package from GNU. GRUB provides a user the choice to boot any one of multiple operating systems installed on a computer, or to select a specific kernel configuration available on a particular operating system’s partitions.
You can find the GRUB file at /boot/grub/grub.cfg, as shown in Figure 2.
Issue the command sudo update-grub and your GRUB file will be modified. You should be able to see an entry for your kernel, which looks like what’s shown below:
### BEGIN /etc/grub.d/05_debian_theme ### set menu_color_normal=white/black set menu_color_highlight=black/light-gray ### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ### menuentry ‘Ubuntu, with Linux 2.6.32-dips+’ --class ubuntu --class gnu-linux --class gnu --class os { recordfail Figure 1: Download the kernel source
![](https://assets.isu.pub/document-structure/211012184157-d26059021e2bb894b5c34e587b6491a9/v1/672e9221d870bbc8a0b61649d3a299bd.jpeg?width=720&quality=85%2C50)
Figure 2: GRUB file
insmod ext2 set root=’(hd0,5)’ search --no-floppy --fs-uuid --set 0b0ebe63-24f6-45c0-a3df5d9c447b5ad9 linux /vmlinuz-2.6.32-dips+ root=UUID=325f1d1d-2070-45f394ed-2027c5ffcbf3 ro quiet splash initrd /initrd.img-2.6.32-dips+
Now, just reboot the system. Your system should now boot up with your just-built kernel. You can verify it by using the uname –a command again.
That’s all you need to build a kernel. Now wasn’t that simple? So, have fun building your kernel!
By: Deepti Sharma
The author is an open source enthusiast with almost a decade of experience in the design, development and quality validation of systems software tools (compilers/assemblers/device drivers) for embedded systems. She loves writing for LFY. She can be reached at deepti.acmet@gmail.com.
New Initiative EFY Group’s EB TimEs
![](https://assets.isu.pub/document-structure/211012184157-d26059021e2bb894b5c34e587b6491a9/v1/8e816181cb815ae19bc7a142f75fa8e1.jpeg?width=720&quality=85%2C50)
Will be launched on Sept 11, 2012
This 8-page monthly B2B Newspaper will be a resource for traders, distributors, dealers, and those who head channel business, as it aims to give an impetus to channel sales