If this blog helped you in any way, please donate a dollar here

Sunday, June 20, 2010

Compiling your own Kernel

Okay... for newbiees compiling the kernel becomes a tough task. Since the typical "./configure && make" will not work for the kernel package. So, this is a step by step walk-through to how to do it.

NOTE: The command `uname -r` gives the kernel version number and will vary from system to system.

1) Firstly download a kernel from here.

2) Extract the tar-ball (with "tar -xvf kernel-file-name")

3) Okay now "cd" to the extracted folder.

4) Run either of
  • make menuconfig
  • make oldconfig
  • make xconfig
  • etc.
Customize the kernel options for whatever reason you want to build the kernel.
As a pointer, you can always change the architecture to whatever architecture you want to run the kernel on. I optimized it for a Pentium 4, since I'll run it on one.

Hack the kernel... be at your heart's peace!

5) Now to generate the final compressed kernel image run this :
  • make bzImage
6) Okay, kernel is ready, but you need the modules for hardware support! Run this:
  • make modules
7) Now comes installation phase. Now to install the modules, run as root:
  • make modules_install
This will copy the compiled modules to /lib/modules/`uname -r`/ folder

8) Now install the kernel with this:

  • make install
This copies th kernel bzImage to /boot directory.

9) To generate the initrd file, we need to cd to /boot directory. Then run this (as root):

  • update-initramfs -c -k `uname -r`
10) Done! Just update your grub or lilo entries to hold the new kernel. If you are using grub2 then simply run : update-grub as root.

11) Now just in case you want to remove all the installed stuff, we'll need to run this:
  • make mproper
And we are back to the previous state.

Okay then... Enjoy hacking!

No comments:

Post a Comment