Wednesday, 19 March 2014

Linux Kernel Version Upgrade


Kernel Version Upgrade
Installing the kernel packages always be safe rather than upgrade as sometimes you may have kernel patches failed. Doing upgrade you will have the option to revert back into the old kernel during kernel patch failures. 
Procedure:
  • First we need to check the installed kernel verion and OS release version
# cat /etc/redhat-release
       Red Hat Enterprise Linux Server release 5.4 (Tikanga)
# uname -r
       2.6.18-164.el5
  • Need to check available latest kernel packages from RHN network, and by observering the list our server kernel is in RHEL 5 Update 4. Hence, we are planning to upgrade our kernel version to the latest verion i.e RHEL5 Update 9
Untitled
  • Require to check installed available packages and grub configuration
# rpm -q kernel kernel-headers kernel-ibcs kernel-pcmcia-cs kernel-source
       kernel-2.6.18-164.el5
     package kernel-headers is not installed
     package kernel-ibcs is not installed
     package kernel-pcmcia-cs is not installed
     package kernel-source is not installed
# rpm -q mkinitrd SysVinit initscripts
       mkinitrd-5.1.19.6-54
     SysVinit-2.86-15.el5
     initscripts-8.45.30-2.el5
# rpm -qa | grep 'kernel'    [we can also check by using this command
       kernel-2.6.18-164.el5
# 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/hda2
           #          initrd /initrd-version.img
           #boot=/dev/hda
           default=0   [default 0 denotes, server should be boot from 1st kernel]
           timeout=5
           splashimage=(hd0,0)/grub/splash.xpm.gz
           hiddenmenu
         title Red Hat Enterprise Linux Server (2.6.18-164.el5)       [first kernel]  
           root (hd0,0)
           kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet
           initrd /initrd-2.6.18-164.el5.img
  • Download RPM package from Redhat Network (RHN), and then install the package by using rpmcommand
NOTE: while using rpm command, do never use “rpm -Uvh” here, as if new kernel upgrade fails, it’s not possible to rollback to the old kernel. If you are using yum command to upgrade, there is no need to take any precautions as yum automatically will make a copy of the old kernel. Even, new kernel upgrade fails also we can boot from old kernel.
NOTE: if your server registered with RHN, and your server version RHEL 5, run fallowing command, then it will install the all the kernel dependency package as well as kernel packages.
# yum install kernel     [it connects to the RHN network]
NOTE: If your server is not register with RHN, we can also achieve by creating yum repository for installaling kernel packages by using new latest OS CD or ISO image. For more details about creating repository, visit procedure after this topic
NOTE: If your server registered with RHM, and your server version RHEL 3 or 4, run fallowing command
# up2date kernel       [it connects to the RHN network]
NOTE: Here I downloaded the package from
http://pkgs.org/centos-5-rhel-5/centos-rhel-i386/kernel-2.6.18-348.el5.i686.rpm/download/
# cd /tmp
# rpm -K *rpm     [to check for md5 algorithm]
         kernel-2.6.18-348.el5.i686.rpm: size md5 OK
            # rpm -ivh kernel-2.6.18-348.el5.i686.rpm
        warning: kernel-2.6.18-348.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID          e8562897
       Preparing…                ########################################### [100%]
       1:kernel                 ########################################### [100%]
# uname –r     [to check the kernel version]
       2.6.18-164.el5
  • Add an entry for latest kernel on /etc/grub.conf file if latest entry not there. Normally it automatically update grub.conf file To do this, server will load the updated kernel in next reboot.
# 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/hda2
          #          initrd /initrd-version.img
          #boot=/dev/hda
          default=0   –>0 is 1st kernel & 1 is 2nd kernel
          timeout=5
          splashimage=(hd0,0)/grub/splash.xpm.gz
          hiddenmenu
        title Red Hat Enterprise Linux Server (2.6.18-348.el5) –>automatically updated
              root (hd0,0)
              kernel /vmlinuz-2.6.18-348.el5 ro root=LABEL=/ rhgb quiet
              initrd /initrd-2.6.18-348.el5.img
         title Red Hat Enterprise Linux Server (2.6.18-164.el5)
              root (hd0,0)
              kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet
              initrd /initrd-2.6.18-164.el5.img
  • To acquire latest version of kernel, we do require to reboot the server
# shutdown -r now
         Broadcast message from root (pts/2) (Tue Apr 23 03:18:32 2013):
           The system is going down for reboot NOW!
  • On console you can see latest kernel version as server is booting latest vesion of the kernel
Untitled
  • Once you get the console access, then you can check kernel version of the server.
# uname -r          [latest kernel version of the RHEL5 ]
         2.6.18-348.el5
# rpm -qa|grep 'kernel'   [Available Kernel Packages]
         kernel-2.6.18-164.el5    [inactive kernel]
           kernel-2.6.18-348.el5     [active kernel]

No comments:

Post a Comment