How to update your kernel on CentOS 6

From Acenet Knowledgebase
Revision as of 11:28, 9 October 2012 by Docs admin (talk | contribs)
Jump to navigation Jump to search

The kernel is the main component of your operating system and provides the core functions for your system's applications. Kernel updates are released periodically as new functionality and, most importantly, security updates are incorporated. This article will show you how to update your system's kernel.

[1] Login to your server via SSH as the root user.

[2] From the command prompt, run: <syntaxhighlight lang="bash"> [root@ /]# yum update kernel </syntaxhighlight>

You will be prompted to accept the new kernel. Note the kernel version displayed and enter "y" to accept the new kernel. In our example, 2.6.32-279.1.1.el6 will be the new version we're installing.

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel x86_64 2.6.32-279.1.1.el6 updates 22 M

Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)

Total download size: 22 M
Is this ok [y/N]: y
After accepting the installation, the kernel will be downloaded and installed. 
Downloading Packages:
kernel-2.6.32-279.1.1.el6.x86_64.rpm | 22 MB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing  : kernel 1/1

Installed: kernel.x86_64 0:2.6.32-279.1.1.el6

Complete!
3) The grub.conf file maintains a list of available kernels and defines which kernel will be used when your operating system starts.  Let's check your server's grub.conf to ensure it's configured to boot the new kernel.  Open the grub.conf file in your favorite text editor, we'll use nano in this example. 
[root@ /]# nano /boot/grub/grub.conf
4)  Let's take a look at an example 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/sda8
# initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-279.1.1.el6)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-279.1.1.el6 ro root=LABEL=/
initrd /boot/initrd-2.6.32-279.1.1.el6.img
title CentOS (2.6.32-220.23.1.el6)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-220.23.1.el6 ro root=LABEL=/
initrd /boot/initrd-2.6.32-220.23.1.el6.img
This line: 
default=1
indicates which kernel will be loaded from the available kernels in this file.  The kernels are referenced starting from zero, so a value of 0 indicates to use the first kernel, 1 indicates to use the second, 2 the third, and so on.  You can see above that "default" has a value of 1, which indicates to use the 2.6.32-220.23.1.el6 kernel on reboot.  Changing this to 0 will cause the first kernel listed to be loaded upon reboot.  Change the "default" value as appropriate to load the new kernel you installed.  Generally, you can change this to 0 and load the top-most kernel listed in grub.conf. 
5) Reboot your server. 
6) Once the server comes back online, login via SSH as the root user.  We'll now check to see that the proper kernel was loaded. We can use the uname command to do this. 
[root@ /]# uname -r
2.6.32-279.1.1.el6

</html>