Linux: Installing a different kernel

From Define Wiki
Jump to navigation Jump to search

Kernels

The best version of the kernel to have for general use is the newest one. It is important to keep your system up todate. This will make sure that all packages will work together and have the latest security updates.

However in certain cases it is required to change the kernel version. Usually this will be the the previous kernel as the newest one isn't yet supported.

Installing a different kernel version does not remove the current one. They will both remain installed. The Grub boot loader controls which kernel is booted.

Installing a new Kernel

To install a new kernel using yum:

yum update kernel

The new kernel will be installed and grub updated to boot by default the new kernel.


Downgrading a Kernel

Note: I'm confirming the exact command to install an old package as yum may require an additional flag.

Note: Downgrading a kernel can result in problems, due to software and package dependencies. Do this only if needed.

To see the available kernels:

yum list available kernel.\* --showduplicates

Install the old kernel:

yum install <kernel-version>

This will not resolve any dependencies. All packages must be manually downgraded.

Grub.conf will be updated, but the defalt kernel will still be the newest version. This must be changed manually to force it to be booted by default.

grub.conf

Grub is the Grand Unified BootLoader. Grub configures how the system is booted.

To change the settings for a one off boot, the settings can be manually changed at the splash screen. Hit any key and GRUB will give you a list of options one for each kernel.

To permanently change the default boot kernel,the grub.conf file must be edited. grub.conf is located in the /etc folder and will look something like this:

# 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/mapper/VolGroup-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-358.14.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-358.14.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-358.14.1.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-358.el6.x86_64.img

Each kernel will be listed on a separate line. To change the default kernel you can change the default variable.

In the example above this has been set to one. This will boot the SECOND kernel (it starts at 0) - so in this case it boots 2.6.32-358.el6.x86_64.

One the file is edited no further action is needed as the file will be re read at boot time.