Friday, September 3, 2010

How to upgrade kernel on linux?


I referred the following steps :

1. cd /usr/local/src
2. wget //replace the version that you want to install or check it at
3. tar -xjvf linux- -C /usr/src
4. cd /usr/src/linux-
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- /usr/src/linux
# ln -s /usr/src/linux- /usr/src/linux-2.6

9. make install

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

* config-
* vmlinuz- and vmlinuz will point here.

example(For my case):

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

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

ln -s /boot/ /boot/
ln -s /boot/vmlinuz- /boot/vmlinuz

10. cd /boot
11. mkinitrd initrd.img- //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-
initrd- 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-]# 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
title CentOS (
root (hd0,0)
kernel /vmlinuz- ro root=/dev/hda3
initrd /initrd-
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-]#

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