How to Compile & Install Linux Kernel 5.0 on CentOS7/RHEL7

Tamir Suliman
2 min readMar 7, 2019

Please support my articles by clicking on the CLAP button. It doesn’t cost you anything to clap.

Step by step guide to compile and install Linux kernel from source code

Introduction

There are different sound reasons to upgrade and compile your kernel some of those main reasons are you are Linux enthusiast want learn how all things work and pieced together;you have a hardware that currently not supported on the current or the standard kernel and you want to have a customized kernel options to experiment or any other reasons.

screenshot of kernel.org website

The following instructions successfully tested on CentOS 7 digital ocean virtual machine “droplet”

The Procedure

The procedure to build (compile) and install the latest Linux kernel from source is as follows:

  1. Install some packages
# yum install make automake vim perl openssl* elfutils-libelf- curl gcc wget flex git build-essential ncurses-devel xz-utils libssl-dev bc flex libelf-dev bison -y

2. Download the Latest Kernel Source

Go to the kernel.org site to download the latest release tarball. Right click on the icon and copy the link then run the wget command to download the file.

# wegt https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.tar.xz
# tar -xf linux-5.0.tar.xz
Linux kernel 5.0 directory list

3. Configuring the kernel

Run the following command:

# make menuconfig

Select the options/features you need (e.g. SCSI support, sound support, networking, etc.) then select save and enter to save the config file.

4. Compilation and Installation

# make kernelImage5
# make modules
# make modules_install
# make install
# sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# sudo grubby - set-default /boot/vmlinuz-5.0.0

5. Reboot the system

# reboot

After the reboot run the following command to verify the information

# uname -sr

Linux 5.0.0

Congratulations!

--

--

Tamir Suliman

Writer, Engineer, Cyber security enthusiast ,PhD. Candidate & 4 Open Source write about my day to day experience in Software Data, and Engineering.