Linux Tutorials

How to upgrade or update kernel of the CentOS 7/ RHEL 7 to Latest stable Kernel

main_kernel_upgrade

The kernel is the core of the operating system, and runs the CPU, manages system memory, controls access to disk drives, and contains device drivers that enable you to interact with the system and use the hardware and peripherals attached to the  computer.Naturally, kernel update  appeals most system administrators who are responsible for wringing the most performance and benefit out of their existing hardware and software. In some cases, rebuilding the kernel(kernel upgrade or kernel update) is required in order to support new hardware that is not supported, or that is poorly supported, by your system’s existing kernel.

Why Should you upgrade/update

  1. Security Fixes
  2. Stability Improvements
  3. Updated Drivers
  4. New Kernel Functions
  5. Increased Speed

for kernel compile you need more memory and processor for faster compilation other wise it will take more time for compile.

i have following configuration

guess_linux_kernel_upgrade1 guess_linux_kernel_upgrade2

Check the current kernel of the system by using uname –r option.

uname –r

guess_linux_kernel_upgrade3

Download latest stable kernel from www.kernel.org.Now the latest stable kernel is 4.7.6

guess_linux_kernel_upgrade4

curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.7.6.tar.xz

guess_linux_kernel_upgrade5 guess_linux_kernel_upgrade6

Then extract the kernel source by using tar –jxvf and copy to /usr/src as follows

tar -Jxvf linux-4.7.6.tar.xz
cp -rf linux-4.7.6 /usr/src

cd /usr/src/
ls

guess_linux_kernel_upgrade7 guess_linux_kernel_upgrade8 guess_linux_kernel_upgrade9 guess_linux_kernel_upgrade10

cd linux-4.7.6

guess_linux_kernel_upgrade11

run the following command for GCC and other development tools

yum group install "Development Tools"

guess_linux_kernel_upgrade13

then install bc to run kernel compile

yum install bc

guess_linux_kernel_upgrade14

Then run the command make mrproper

make mrproper

guess_linux_kernel_upgrade12

then run following command

yum install ncurses-devel ncurses

guess_linux_kernel_upgrade15

Then run the command make menuconfig

make menuconfig

guess_linux_kernel_upgrade12 guess_linux_kernel_upgrade16 guess_linux_kernel_upgrade17 guess_linux_kernel_upgrade18 guess_linux_kernel_upgrade19

just set as default if you want to modify you can modify and then save and exit

Now install the package openssl-devel package by using yum

yum install openssl-devel

guess_linux_kernel_upgrade22

Then run the command make it takes a moment please be patient and wait.

make

i have 8 cpu so i run

make -j8

guess_linux_kernel_upgrade27

Then run the command make modules

make modules -j8

guess_linux_kernel_upgrade20 guess_linux_kernel_upgrade21 guess_linux_kernel_upgrade25 guess_linux_kernel_upgrade26 guess_linux_kernel_upgrade28 guess_linux_kernel_upgrade29

now install modules by using the command make modules_install.

make modules_install -j8

guess_linux_kernel_upgrade30 guess_linux_kernel_upgrade32

Now run the command make install

make install -j8

guess_linux_kernel_upgrade33

Following command can be used to list the kernels in centos 7

egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'

guess_linux_kernel_upgrade39

reboot the system by using following command

reboot

You can use grub2-set-default command to set default boot kernel, to set first kernel in grub2.cfg as default run and reboot.

here i have in second that why i run following command

grub2-set-default 1

guess_linux_kernel_upgrade40

then remove unused kernel

yum list kernel.*

yum remove kernel-version number

i have run the following command as per my version

yum remove kernel-3.10.0-327.36.1.el7

guess_linux_kernel_upgrade42 guess_linux_kernel_upgrade43 guess_linux_kernel_upgrade44

Testing

run the following command

name -r

guess_linux_kernel_upgrade41

 

Remove Build Folder

guess_linux_kernel_upgrade45

Thank You

1 Comment

  • I enjoy what you guys are usually up too. This type of clever work and coverage!
    Keeep up the superb works guys I’ve incorporated you guys to my
    own blogroll.

Leave a Comment