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

From Acenet Knowledgebase
Jump to: navigation, search
(test)
 
m
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<html> 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.  
+
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.  
1Login to your server via SSH as the root user.  
+
 
2) From the command prompt, run:  
+
[1] Login to your server via SSH as the root user.  
<div class="code_style">[root@ /]# yum update kernel</div>
+
 
You will be prompted to accept the new kernel.  Note the kernel version displayed and enter "y" to accept the new kernel.  
+
[2] From the command prompt, run:  
In our example, 2.6.18-308.8.2.el5 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.18-308.8.2.el5                     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.  
+
[root@ /]# yum update kernel*
<div class="code_style">Downloading Packages:<br />kernel-2.6.18-308.8.2.el5.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.18-308.8.2.el5<br /><br />Complete!</div>
+
</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.  
+
 
<div class="code_style">[root@ /]# nano /boot/grub/grub.conf</div>
+
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.18-308.8.2.el5 will be the new version we're installing.  
4Let's take a look at an example grub.conf.  
+
 
<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.18-308.8.2.el5)<br />        root (hd0,0)<br />        kernel /boot/vmlinuz-2.6.18-308.8.2.el5 ro root=LABEL=/<br />        initrd /boot/initrd-2.6.18-308.8.2.el5.img<br />title CentOS (2.6.18-274.3.1.el5)<br />        root (hd0,0)<br />        kernel /boot/vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/<br />        initrd /boot/initrd-2.6.18-274.3.1.el5.img<br />title CentOS (2.6.18-238.19.1.el5)<br />        root (hd0,0)<br />        kernel /boot/vmlinuz-2.6.18-238.19.1.el5 ro root=LABEL=/<br />        initrd /boot/initrd-2.6.18-238.19.1.el5.img</div>
+
<syntaxhighlight lang="bash">
This line:  
+
================================================================================
<div class="code_style">default=1</div>
+
Package             Arch       Version             Repository           Size
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.  
+
Installing:
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.  
+
  kernel             x86_64     2.6.18-308.8.2.el5   updates             22 M
<div class="code_style">[root@ /]# uname -r<br />2.6.18-308.8.2.el5</div></html> [[Category:CentOS 5]]
+
 
 +
Transaction Summary
 +
================================================================================
 +
Install          1 Package(s)
 +
Upgrade      0 Package(s)
 +
 
 +
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.18-308.8.2.el5.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.18-308.8.2.el5
 +
 
 +
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.18-308.8.2.el5)
 +
        root (hd0,0)
 +
        kernel /boot/vmlinuz-2.6.18-308.8.2.el5 ro root=LABEL=/
 +
        initrd /boot/initrd-2.6.18-308.8.2.el5.img
 +
title CentOS (2.6.18-274.3.1.el5)
 +
        root (hd0,0)
 +
        kernel /boot/vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/
 +
        initrd /boot/initrd-2.6.18-274.3.1.el5.img
 +
title CentOS (2.6.18-238.19.1.el5)
 +
        root (hd0,0)
 +
        kernel /boot/vmlinuz-2.6.18-238.19.1.el5 ro root=LABEL=/
 +
        initrd /boot/initrd-2.6.18-238.19.1.el5.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.18-308.8.2.el5
 +
</syntaxhighlight>
 +
 
 +
[[Category:CentOS 5]]

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.18-308.8.2.el5 will be the new version we're installing.

================================================================================
 Package             Arch       Version              Repository           Size
================================================================================
 Installing:
  kernel             x86_64     2.6.18-308.8.2.el5   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.18-308.8.2.el5.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.18-308.8.2.el5

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.18-308.8.2.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-308.8.2.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-308.8.2.el5.img
title CentOS (2.6.18-274.3.1.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-274.3.1.el5.img
title CentOS (2.6.18-238.19.1.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-238.19.1.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-238.19.1.el5.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.18-308.8.2.el5