kernelKernel 

 It makes sure that all processes in the system works fine

Rebuilding

It is done to optimize the kernel to suit our requirements as well as make it more secure from internet attacks

 Steps


1. Determining the current hardware 
 This is required during configuration process to enable hardwares that our new kernel has to support.
Commands used for the same are:

 

 


/sbin/lspci 
cat /proc/cpuinfo

2. Download the Source
latest sources and its corresponding patches are always available fromhttp://www.kernel.org/pub/linux/kernel/
 As of today (Oct 21, 2008) the latest available source is linux-2.6.27.2.tar.gz and the patch is patch-2.6.27.2.gz

Apply the patches

Extract the source using tar -zxvf and patch using gunzip to /usr/src/ folder.

Now cd to linux-2.6.27.2 and apply the patch as shown below:


 patch -p1 <../patch-2.6.27.2

4. Configuration
 You may copy the current configuration by copying the file .config.

 

cp ../linux/.config config.old

 Begin the configuration by wiping out all previous configurations and resetting the source directory to a pristine state:

 

 
$ make mrproper

 

Run the configuration utility. Either of the below step can be used to run the configuration utility:

 

  make config – least friendly tool
  make oldconfig         (- will read the defaults from the existing .config file. Note that oldconfig will only work within the same major version of the kernel. You cannot, for example, use a 2.4.x .config with the 2.6.x kernel.)
 make menuconfig      (- Most commonly and recommended method. Gives you a graphical front end to select your options)

5. Start Build
Clean before the build:

 

 
 make clean

 Start the build after cleaning process:

 

make bzImage

6. Build and install all the loadable modules

 
  make modules
 make modules_install

7. Copy the required files and generate initrd
 Copy the files over for the kernel itself

 
 cp .config /boot/config-2.6.27.2
 cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.27.2
 cp System.map /boot/System.map-2.6.27.2
 mkinitrd /boot/initrd-2.6.27.2.img 2.6.27.2

 If you come across an error like: “/dev/mapper/control: open failed: No such file or directory” , Run the following commands:

 
  rm -rf /boot/initrd-2.6.27.2.img
  mkinitrd –omit-lvm-modules /boot/initrd-2.6.27.2.img 2.6.27.2

8. Configure Grub & enable failsafe
  Open grub.conf file
  Add the below code to the top of the kernel list:

 

title Red Hat Linux (2.6.27.2)
root (hd0,0)
kernel /vmlinuz-2.6.27.2 ro root=LABEL=/
initrd /initrd-2.6.27.2.img

  Set the default value to your working kernel. (NOTE: NOT NEW KERNEL)
  Now save and exit from grub.conf file and enter into grub mode by typing “grub” from bash prompt
  And set to boot from newly compiled kernel during next reboot:

 

  savedefault –default=0 –once

 If your server is up, you are done with your new kernel. Open the file grub.conf and change the value of default to “0″

Congratulations! You are done with your new kernel.