search
HomeOperation and MaintenanceCentOSHow to compile and install a new version of the kernel from source code under CentOS

How to compile and install a new version of the kernel from source code under CentOS

How to compile and install a new version of the kernel from source code under CentOS?

At work, many times due to the need to use new technical solutions, a newer version of the kernel is needed to support new functions, and the kernel version that comes with the CentOS system is generally older, so we The system kernel needs to be upgraded and a new version of the kernel needs to be installed. Here, taking the CentOS 7 system as an example, the process of compiling and installing the latest version of the kernel is summarized as follows:

1. Download the latest stable version of the kernel source code package to /usr/local/ src and extract it to the current directory

How to compile and install a new version of the kernel from source code under CentOS

##2. Unzip the kernel source package

How to compile and install a new version of the kernel from source code under CentOS

#3. Copy the existing version of the kernel compilation config configuration file from the /boot directory to the new kernel source code decompression directory and rename it For the hidden file of .config

[root@localhost src]# cd linux-5.2.11
[root@localhost linux-5.2.11]# cp /boot/config-3.10.0-957.el7.x86_64 ./.config

Copying the original kernel config file from the boot directory is mainly for convenience. This file saves the module configuration information installed by the kernel when installing the system (otherwise it needs to be reinstalled Manually specify the compilation configuration for each module).

4. Install dependency packages

Install development tool package group

[root@localhost linux-5.2.11]# yum -y groupinstall "development tools"

Install ncurse-devel package (make menuconfig text interface window dependency package)

[root@localhost linux-5.2.11]# yum -y install ncurses-devel

5. Run make menuconfig and open the compilation options menu window of the text interface. You can adjust the module compilation options loaded by the kernel, such as modifying the compiled kernel name and adding new modules that were missing from the previous system. wait.

Modify the kernel name:

General setup --->local version -append to kernel release

Modify the kernel name here to

5.2.11-001.el7.x86_64

How to compile and install a new version of the kernel from source code under CentOS

Newly added NTFS file system support module:

File systems --->DOS/FAT/NT Filesystems --->NTFS file system support

How to compile and install a new version of the kernel from source code under CentOS

It is recommended to compile in module mode (M option). (The * sign is statically compiled and packaged into the kernel file. If there are more newly added modules, the size of the kernel file will increase)

6. Compile the kernel

[root@localhost linux-5.2.11]# make -j 4  #根据CPU核数开启多线程编译以加快编译速度

How to compile and install a new version of the kernel from source code under CentOS

Start the long compilation process, which will take about 1-2 hours, depending on the performance of the CPU hardware.

If an error is prompted at the beginning of compilation, you may need to install the corresponding component package in advance, for example:

[root@localhost linux-5.2.11]# yum -y install openssh-devel elfutils-libelf-devel bc

According to the corresponding error prompt, install the corresponding component package in yum mode, and some component packages are in epel source, so the epel source warehouse needs to be configured in advance.

7. Compile and install the module

After the compilation is completed, execute make modules_install to install the kernel module

[root@localhost linux-5.2.11]# make modules_install

8. Install the kernel core file

[root@localhost linux-5.2.11]# make install

reboot

If you need to set the new version of the kernel as the default startup kernel, you can use this command

grub2-set-default 0  #0表示 /boot/grub2/grub.cfg 文件中排在第一位的 menuentry 段

After restarting the system, check the kernel version. It is the latest version 5.2.11

[root@localhost ~]# uname -r
5.2.11-001.el7.x86_64

At this point, the entire kernel compilation and installation process is completed.

Related references:

centOS tutorial

The above is the detailed content of How to compile and install a new version of the kernel from source code under CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
CentOS: A Community-Driven Linux DistributionCentOS: A Community-Driven Linux DistributionApr 17, 2025 am 12:03 AM

CentOS is a stable, enterprise-grade Linux distribution suitable for server and enterprise environments. 1) It is based on RedHatEnterpriseLinux and provides a free, open source and compatible operating system. 2) CentOS uses the Yum package management system to simplify software installation and updates. 3) Support advanced automation management, such as using Ansible. 4) Common errors include package dependency and service startup issues, which can be solved through log files. 5) Performance optimization suggestions include the use of lightweight software, regular cleaning of the system and optimization of kernel parameters.

What Comes After CentOS: The Road AheadWhat Comes After CentOS: The Road AheadApr 16, 2025 am 12:07 AM

Alternatives to CentOS include RockyLinux, AlmaLinux, OracleLinux, and SLES. 1) RockyLinux and AlmaLinux provide RHEL-compatible binary packages and long-term support. 2) OracleLinux provides enterprise-level support and Ksplice technology. 3) SLES provides long-term support and stability, but commercial licensing may increase costs.

CentOS: Exploring the AlternativesCentOS: Exploring the AlternativesApr 15, 2025 am 12:03 AM

Alternatives to CentOS include UbuntuServer, Debian, Fedora, RockyLinux, and AlmaLinux. 1) UbuntuServer is suitable for basic operations, such as updating software packages and configuring the network. 2) Debian is suitable for advanced usage, such as using LXC to manage containers. 3) RockyLinux can optimize performance by adjusting kernel parameters.

Centos shutdown command lineCentos shutdown command lineApr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Difference between centos and ubuntuDifference between centos and ubuntuApr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Centos configuration IP addressCentos configuration IP addressApr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to install centosHow to install centosApr 14, 2025 pm 09:03 PM

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

Centos8 restarts sshCentos8 restarts sshApr 14, 2025 pm 09:00 PM

The command to restart the SSH service is: systemctl restart sshd. Detailed steps: 1. Access the terminal and connect to the server; 2. Enter the command: systemctl restart sshd; 3. Verify the service status: systemctl status sshd.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools