Friday, September 3, 2010

How to upgrade kernel on linux?

Guys,

I referred the following steps :

============================
1. cd /usr/local/src
2. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2 //replace the version that you want to install or check it at http://www.kernel.org/
3. tar -xjvf linux-2.6.35.4.tar.bz2 -C /usr/src
4. cd /usr/src/linux-2.6.35.4
5. make menuconfig //if gcc is not there just install it like : yum install gcc

Note : You can enable various option here. But make it sure that you have enabled kernel config option. Go to General option >> Kernel .config support(enter space) and exit. (save the changes). make oldconfig > Use when upgrading kernel, only asks if new options.

6. make
7. make modules
8. make modules_install

Note(Do the following) : # ln -s /usr/src/linux-2.6.35.4 /usr/src/linux
# ln -s /usr/src/linux-2.6.35.4 /usr/src/linux-2.6

9. make install

Note : It will install three files inside the /boot directory :

* System.map-2.6.35.4
* config-2.6.35.4
* vmlinuz-2.6.35.4 and vmlinuz will point here.

example(For my case):

----------
root@server [/usr/src/linux-2.6.35.4]# make install
sh /usr/src/linux-2.6.35.4/arch/x86/boot/install.sh 2.6.35.4
arch/x86/boot/bzImage \
System.map "/boot"
root@server [/usr/src/linux-2.6.35.4]#
root@server [/boot]# ll |grep 2.6.35.4
-rw------- 1 root root 2586318 Sep 3 18:00 initrd-2.6.35.4.img
lrwxrwxrwx 1 root root 25 Sep 3 18:00 System.map ->
/boot/System.map-2.6.35.4
-rw-r--r-- 1 root root 1360605 Sep 3 18:00 System.map-2.6.35.4
lrwxrwxrwx 1 root root 22 Sep 3 18:00 vmlinuz -> /boot/vmlinuz-2.6.35.4
-rw-r--r-- 1 root root 2653408 Sep 3 18:00 vmlinuz-2.6.35.4
root@server [/boot]

Make sure System.map and vmlinuz are pointing to latest kernel else point them like :

ln -s /boot/System.map-2.6.28 /boot/System.map
ln -s /boot/vmlinuz-2.6.35.4 /boot/vmlinuz
-----------

10. cd /boot
11. mkinitrd initrd.img-2.6.35.4 2.6.35.4 //You may not be needed this step. For me it has automatically created. This is creation of RAM driver.

Example for my case :

------------
root@server [/boot]# mkinitrd initrd-2.6.35.4.img 2.6.35.4
initrd-2.6.35.4.img already exists.
root@server [/boot]#
------------

12. vi /boot/grub/menu.lst or /etc/grub.conf : //For me the entries has automatically put in this file like :

------------
root@server [/usr/src/linux-2.6.35.4]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda3
# initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.35.4)
root (hd0,0)
kernel /vmlinuz-2.6.35.4 ro root=/dev/hda3
initrd /initrd-2.6.35.4.img
title CentOS (2.6.18-194.8.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.8.1.el5 ro root=/dev/hda3
initrd /initrd-2.6.18-194.8.1.el5.img
title CentOS (2.6.18-128.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/hda3
initrd /initrd-2.6.18-128.el5.img
root@server [/usr/src/linux-2.6.35.4]#
------------

13. reboot //enter this command at the konsole.
14. Check the server whether it comes online and check uname -r //If it does not come please contact DC to load the server from old kernel and sort the problem.
==============================

That's it. Try :)

1 comment:

  1. Hi,

    It will be better in step 13, we can go for a boot once, instead of direct reboot.
    ===
    echo "savedefault --default=2 --once" | grub --batch
    ===

    ReplyDelete