Difference between revisions of "How to update your kernel on CentOS 6"

From Acenet Knowledgebase
Jump to: navigation, search
m
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
[1] Login to your server via SSH as the root user.  
 
[1] Login to your server via SSH as the root user.  
  
[2] From the command prompt, run:  
+
[2] From the command prompt, run:  
 +
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
[root@ /]# yum update kernel
+
[root@ /]# yum update kernel*
 
</syntaxhighlight>
 
</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.  
 
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.  
  
<div class="code_style">================================================================================<br /> Package                             Arch                             Version                                       Repository                       Size<br />================================================================================<br /> Installing:<br />  kernel                               x86_64                         2.6.32-279.1.1.el6                     updates                           22 M<br /><br /> Transaction Summary<br /> ================================================================================<br />Install          1 Package(s)<br /> Upgrade      0 Package(s)<br /><br /> Total download size: 22 M<br />Is this ok [y/N]: y</div>
+
<syntaxhighlight lang="bash">
After accepting the installation, the kernel will be downloaded and installed.  
+
================================================================================
<div class="code_style">Downloading Packages:<br />kernel-2.6.32-279.1.1.el6.x86_64.rpm                                                                                             |  22 MB    00:02<br />Running rpm_check_debug<br />Running Transaction Test<br />Finished Transaction Test<br />Transaction Test Succeeded<br />Running Transaction<br />  Installing    : kernel                                                                                                                                             1/1<br /><br />Installed:  kernel.x86_64 0:2.6.32-279.1.1.el6<br /><br />Complete!</div>
+
Package             Arch       Version             Repository           Size
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.  
+
================================================================================
<div class="code_style">[root@ /]# nano /boot/grub/grub.conf</div>
+
Installing:
4Let's take a look at an example grub.conf.  
+
  kernel             x86_64     2.6.32-279.1.1.el6   updates             22 M
<div class="code_style"># grub.conf generated by anaconda<br /> #<br /> # Note that you do not have to rerun grub after making changes to this file<br /> # NOTICE:  You have a /boot partition.  This means that<br /> #          all kernel and initrd paths are relative to /boot/, eg.<br /> #          root (hd0,0)<br /> #          kernel /vmlinuz-version ro root=/dev/sda8<br /> #          initrd /initrd-version.img<br /> #boot=/dev/sda<br /> default=1<br /> timeout=5<br /> splashimage=(hd0,0)/grub/splash.xpm.gz<br /> hiddenmenu<br />title CentOS (2.6.32-279.1.1.el6)<br />        root (hd0,0)<br />        kernel /boot/vmlinuz-2.6.32-279.1.1.el6 ro root=LABEL=/<br />        initrd /boot/initrd-2.6.32-279.1.1.el6.img<br />title CentOS (2.6.32-220.23.1.el6)<br />        root (hd0,0)<br />        kernel /boot/vmlinuz-2.6.32-220.23.1.el6 ro root=LABEL=/<br />        initrd /boot/initrd-2.6.32-220.23.1.el6.img</div>
+
 
This line:  
+
Transaction Summary
<div class="code_style">default=1</div>
+
================================================================================
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.  
+
Install          1 Package(s)
5) Reboot your server.  
+
Upgrade      0 Package(s)
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.  
+
 
<div class="code_style">[root@ /]# uname -r<br />2.6.32-279.1.1.el6</div></html> [[Category:CentOS 6]]
+
Total download size: 22 M
 +
Is this ok [y/N]: y
 +
</syntaxhighlight>
 +
 
 +
After accepting the installation, the kernel will be downloaded and installed.  
 +
 
 +
<syntaxhighlight lang="bash">
 +
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!
 +
</syntaxhighlight>
 +
 
 +
[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.  
 +
 
 +
<syntaxhighlight lang="bash">
 +
[root@ /]# nano /boot/grub/grub.conf
 +
</syntaxhighlight>
 +
 
 +
[4] Let's take a look at an example grub.conf.  
 +
 
 +
<syntaxhighlight lang="bash">
 +
# 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
 +
</syntaxhighlight>
 +
 
 +
This line:  
 +
 
 +
<syntaxhighlight lang="bash">
 +
default=1
 +
</syntaxhighlight>
 +
 
 +
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.18-274.3.1.el5 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.  
 +
 
 +
<syntaxhighlight lang="bash">
 +
[root@ /]# uname -r
 +
2.6.32-279.1.1.el6
 +
</syntaxhighlight>
 +
 
 +
[[Category:CentOS 6]]

Latest revision as of 16:52, 21 April 2013

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:

[root@ /]# yum update kernel*

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.18-274.3.1.el5 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