Compile Linux Kernel on CentOS7

28/12/2020
Chưa phân loại

Compile the Latest Linux Kernel from Source on CentOS 7

In this article I will show you how to download the latest Linux kernel source from the official website of Linux kernel, compile Linux kernel from source and use the compiled kernel on CentOS 7. Let’s get started.

Checking Currently Used Kernel:

You can see from the following screenshot that I am using CentOS 7.

And the current kernel version is 3.10

Installing the prerequisites:

To compile the latest Linux kernel from source on CentOS 7, you must have a build tool and some other packages installed on your CentOS 7 operating system.

Before you install anything, run the following command to update package cache:

$ sudo yum makecache

Now you can install the compilers and libraries required for compiling the kernel with the following command:

$ sudo yum install ncurses-devel make gcc bc openssl-devel

Press ‘y’ and then press <Enter> to continue.

The build tools should be installed.

Now you have to install elfutils package. Run the following command to install it:

$ sudo yum install elfutils-libelf-devel

Press ‘y’ and press <Enter> to continue.

‘elfutils’ should be installed.

Now you have to install rpm-build with the following command:

$ sudo yum install rpm-build

Press ‘y’ and then press <Enter> to continue.

‘rpm-build’ package should be installed.

Downloading the Linux Kernel Source:

Go to the official website of Linux Kernel at https://www.kernel.org and you should be the following page.

Click on the “Latest Stable Kernel” button as marked on the screenshot below.

Your browser should prompt you to save the file. Just click on “Save File” and click on “OK”.

Your download should begin.


Compiling the Kernel:

Once the download is complete, navigate to the directory where you downloaded the file. In my case it is the Downloads directory in my user’s HOME directory.

$ cd ~/Downloads

From the output of ‘ls’ you can see that the downloaded file is ‘linux-4.14.10.tar.xz’. Which is a compressed tar file.

Now extract the compressed tar file with the following command:

$ tar xvf linux-4.14.10.tar.xz

tar is extracting the compressed file.

Once the file is extracted, you should see the following window.

After extraction, you should see a new directory as marked red in the screenshot below. Navigate to the directory with the following command.

$ cd linux-4.14.10

If you run the following command, you should see a list of config files used by the kernels that are installed on your system. You can run ‘uname -r’ command to find the one that you need. The filename should match with the output of the ‘uname -r’ command.

Then copy the config file to the linux-4.14.10 directory with the following command:

$ sudo cp -v /boot/config-3.10.0-693.el7.x86_64 .config

Now run the following command:

$ make menuconfig

You should see the following window. This is where you enable or disable certain kernel features. If you don’t know what to do here, then just leave the defaults.

Once you’re done, press <Left Arrow> button several times and go to “< Save >” as shown in the screenshot below. Then press <Enter>.

Then press <Enter> again.

Press <Enter> again.

Now navigate to “< Exit >” and press <Enter>

The .config file is updated for the new kernel.

Before you start compiling the new kernels, make sure you have more than 20GB of free space on the filesystem where you’re compiling the kernel.

You can check how much space you have available with the following command:

$ df -h

 

Now run the following command to start the compilation process:

$ make rpm-pkg

The kernel should be compiling just fine. It should take a long time.

On completion, you should see the following window. Some rpm package file was created on the user’s home directory as you can see from the screenshot.

The generated rpm package files.

Now you can run the following command to install the rpm packages:

$ sudo rpm -iUv ~/rpmbuild/RPMS/x86_64/*.rpm

Once the installation is complete, run the following command to restart your computer.

$ reboot

Once your computer starts, you can run the following command to check the version of the kernel that you’re currently using.

$ uname -r

You should see that it’s the version that you just installed. For me, it is ‘4.14.10’.

So that’s how you compile the latest kernel from source and use it on CentOS 7. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Thuê proxy v6 kéo view Youtube ở đâu uy tín, chất lượng?

Nền tảng mạng xã hội Youtube hiện đang có lượng người dùng khổng lồ trên thế giới. Đây vừa...
05/10/2023

Top 10 Python IDE for Ubuntu

Python is one of the most widely used general purpose programming languages. Many of the popular websites or application...
28/12/2020

IPv4 là gì? nhà cung cấp IPv4 uy tín Việt Nam

IPv4 là một giao thức internet phiên bản thứ 4, đã được Bộ Quốc phòng Mỹ chuẩn hóa trong bản...
27/09/2021
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024