Linux - Kernel recompilation steps, How to do kernel Compilation

Kernel recompilation steps


Kernel

Kernel Recompilation Steps

1. Download the latest kenel from www.kernel.org to /usr/src

2. Unpack the tar ball
# tar -zxvf linux-x.x.x.tar.gz

# cd linux-x.x

3. backup the .config file from /boot

4. Run the command make mrproper to remove the config file
# make mrproper
this removes the current .config and other files

5. Now lets start for kernel compilation
# make config

# make menuconfig 
it open a dialog box in the terminal

OR

# make xconfig 
for X-based GUI with modular explanations

6. Now install the dependencies for the kernel
# make dep
This will install any dependencies needed for the modules selected in previous command

7. Clean the compiled source
#make clean
to clean your sources for they compile correctly

8. Create the kernel image
make bzImage
to make the kernel image (compile and creates compressed image of kernel)

9. Compile your selected modules
make modules

10. To install newly compile modules (installs to /lib/modules/linux.x.x.x)
make modules_install

11. Then copy the newly created kernel and system.map to /boot
# cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-x.x.x 

# cp /usr/src/linux/System.map /boot/System.map-x.x.x

/sbin/mkinitrd /boot/initrd-x.x.x.img x.x.x  - to create initrd image

eg : /sbin/mkinitrd /boot/initrd-2.6.18.img 2.6.18
The last set of x.x.x is the eqivalent to your new kernel version and it looks to /lib/modules for that version.

And Finally Edit Your /etc/grub.conf file
# vi /etc/grub.conf
title New Kernel <any name> kernel /vmlinuz-x.x.x ro root=LABEL=/ initrd /initrd-x.x.x.img

Note: look at the previous parameters in the grub.conf file and note what "root=" and use what is existing.

change the default value to the new kernel

Exit and Save grub.conf

OR

11a. Follow the step 11 to do above setup
make install

This will do all the above steps automatically
 --> this will copy vmlinuz, system.map file 
 --> create initrd.img file 
 --> Will add an entry in grub.conf file.

12. change the default value to the new kernel

13. add "fallback=" variable

Now REBOOT the system, that's it you have successfully compile the kernel. Now you have installed a new kernel.

The topic on Linux - Kernel recompilation steps is posted by - Krish

Hope you have enjoyed, Linux - Kernel recompilation stepsThanks for your time

Tech Bluff