Thursday, November 6, 2008

Build your first kernel

LINUX BASICS COMPILING KERNEL

Well to my bad luck when i started, i chose a linux machine with redhat linux and when i started the system Remember the first time i was using linux) the OS did not boot, somebody had reset the pc and i had an unclean shutdown.

Actually windows automatically asks you for this, but linux does not. Remember there is more to it, later i realized about filesystem and journals and the problem wont come for ext3 and above file systems!!.

On the linux desktop right click and open a new terminal.

1. Booting problem: Single user mode boot has to be done because there can be a “unclean shutdown”
2. Get what kernel version you are using: uname –r
3. Target an upgraded version to download
4. Learn the vi editor commands :)
5. Below things to be done in kernel directory
6. Get the latest version of Linux kernel from net and use the following commands


a. su –
b. Above will take you in admin mode (I call it that way)
c. Copy the downloaded file in /tmp folder
d. # tar –xjvf linux-2.6.25.tar.bz2 – C /usr/src
e. Above will make a new directory of linux-2.6.25 in src folder whr other kernels will also be thr
f. To choose kernel options type below
g. # make menuconfig / menu xconfig / menu gconfig
h. Create a compressed kernel image using: make
i. Compile kernel using: make modules (This might take an hour, if first time)
j. Install kernel modules: make modules_install
k. Now install kernel: make install

i. Above will install three files in /boot directory and also modify the kernel grub configuration file


1. system.map-2.6.25
2. config-2.6.25
3. vmlinuz-2.6.25



7. Create an initrd image (Optional)

a. cd / boot
b. mkinitrd –o initrd-2.6.25.img 2.6.25


8. Modify the grub configuration file

a. # vi /boot/grub/menu.lst



i. In the kernel row append it by enforcing=0
ii. enforcing=0 is very important here ... this is actually disabling any SELinux stuff and letting the kernel boot (Security disabled etc etc)
iii. If enforcing is not done, the kernel uncompresses itself ... and then the kernel panics ... you will get an error that Kernel panic : not syncing : attempted to kill init


9. Now reboot the system so that you can boot using new Kernel: # reboot