


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
##2. Unzip the kernel source package
#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 ./.configCopying 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 releaseModify the kernel name here to
5.2.11-001.el7.x86_64
File systems --->DOS/FAT/NT Filesystems --->NTFS file system support
6. Compile the kernel
[root@localhost linux-5.2.11]# make -j 4 #根据CPU核数开启多线程编译以加快编译速度
[root@localhost linux-5.2.11]# yum -y install openssh-devel elfutils-libelf-devel bcAccording 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 installrebootIf 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_64At this point, the entire kernel compilation and installation process is completed. Related references:
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!

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.

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.

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.

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.

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)

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

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.

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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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
Visual web development tools