In this post I want to show you how to compile Linux kernel. I will compile the version 188.8.131.52 which is the latest stable version at the time of writing this post.
I use Debian GNU/Linux, with Linux 2.6.32-5-amd64 with grub2 but generally you can use any distribution to compile it.
Generally compiling and using your own Linux kernel is so easy but if you want to get involved more and want to manipulate some modules! It will be a little hard. But it is so exiting when you work with your own compiled Linux.
Here is the instruction:
Get the latest Linux kernel from Kernel.org I use the version 184.108.40.206 which is the latest stable version at the time of writing this post.
Unzip the archive using the following command.
$ bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf
Replace your own version with XX in the above command.
There is README file in extracted directory that will help you to customize your compile.
- Now call menuconfig function to config and customize kernel to compile. This command will show you a window to select and deselect different modules to compile.
$$ make O=/home/name/build/kernel menuconfig
The O= option determines the target directory to copy built files. If you use this option for this command you should use it for other commands too.
- After config, use following command to make kernel. all files will be copied into /home/name/build/kernel
$$ make O=/home/name/build/kernel
- Know use this command to install modules.
$$ sudo make O=/home/name/build/kernel modules_install install
This command will copy following files into /boot directory.
- Know use following command to make a Ram Disk.
$$ cd /boot
$$ mkinitramfs -o initrd.img-2.6.XX 2.6.XX
Note: some in distributions you should use mkinitrd -o initrd.img-2.6.XX 2.6.XX command to make a ram disk.
- Finally if you are using grub2, use following command to update grub and introduce newly compiled kernel to grub. This command will automatically scan /boot directory and update the /boot/grub/grub.cfg. You should just execute the following command.
Note: if you are using grub 1.x use menu.lst to introduce newly complied kernel.
Now reboot your system. You will see a new item with the version of compiled kernel. In grub menu. Just select it and boot your system and enjoy using your own compiled Linux.I have worked for many software developing companies and I was amazed to see that majority of coders and developers does not knew these strings of linux.