Wednesday, June 11, 2008

Let's compile latest linux kernel (as easy as 1-2-3)

contents:
1. Pre-compilation installations
2. Download the latest kernel
3. Configure & compiling the kernel

NOTE

A:i used ubuntu 7.10 gutsy gibbon for this entire blog & logged in as root
though it's not advisable cause you might do something wrong unknowingly

B:do it at your own risk,but don't panic if something goes wrong.
you can find help online.I had to compile the kernel 3 times myself to get all things going.

C:things you should know
#cat /proc/cpuinfo
this gives you your CPU type
#cat /proc/meminfo
this gives you your PC's memory information
#lsmod
this gives you information about the modules currently loaded by the kernel
use this to get information about your soundcard, snd_intel_hda in my case

Disclaimer

Building and using a custom kernel will make it very difficult to get support for your system. While it is a learning experience to compile your own kernel, you will not be allowed to file bugs on the custom-built kernel (if you do, they will be Rejected without further explanation).

If you have a commercial support contract with Ubuntu/Canonical, this will void such support.



1. pre-compilation installations

we need to install all the essential things need to compile the kernel.
# sudo apt-get install build-essential

2. Download the latest kernel

you can get the full source code for the latest kernel at www.kernel.org
# cd /tmp

# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src

# cd /usr/src/

3.Configure & compile the kernel

before compiling the kernel you need to copnfigure it according to your needs
for the same use the following command & configure your kernel according to the information shown in the output of
"#cat /proc/cpuinfo" & "#cat /proc/meminfo"

#make menuconfig

this will show a text based menu system in the terminal
to get a GUI menu use

#menu xconfig

note:please try to find out more about how & what to configure

half of the most essential part of the process is done

It will take a long time to compile the whole kernel,so have a cup of coffee ready.
Now to compile the kernel issue following command for debian linux
#make-kpkg --initrd --append-to-version=-some-string-here kernel-image kernel-headers
you can replace the part "-some-string-here" with any thing you like lets say "custom"

& thats it

check if the file /boot/grub/menu.lst is updated with your new kernel or not...

for detailed information on how to compile a kernel you can view ubuntu community docs.

No comments: