WhatsApp
Request a Quote
Leave Your Message
Three ways to upgrade the kernel of industrial computer CentOS system
Blog

Three ways to upgrade the kernel of industrial computer CentOS system

2024-10-17 15:08:44

During the use of CentOS, it is inevitable to upgrade the kernel, but sometimes due to source code compilation dependency issues, not all programs support the latest kernel version, so the following will introduce three ways to upgrade the kernel.

Note:
About kernel types:
The ml in kernel-ml is the abbreviation of [mainline stable] in English, and the latest stable mainline version is listed in elrepo-kernel.
The lt in kernel-lt is the abbreviation of [long term support] in English, and the long-term support version is listed in elrepo-kernel.
Check the kernel version
uname -r

图片 1
Table of Contents

1. yum installation

1. Import the repository source
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
2. View the installable packages
yum --enablerepo="elrepo-kernel" list --showduplicates | sort -r | grep
kernel-ml.x86_64
3. Select ML or LT version to install
If no version is specified, the latest version is installed by default
Install ML version
yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
Install LT version, select this for all K8S
yum --enablerepo=elrepo-kernel install kernel-lt-devel kernel-lt -y
4. Check the current kernel boot sequence
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
5. Modify the default boot item
xxx is the serial number, which specifies the xth item in the boot list as the boot item, and x starts counting from 0
grub2-set-default xxxx
For example, if you want to set it to boot with kernel 4.4
then directly enter "grub2-set-default 0", and you can start from 4.4 the next time you start
Check the kernel boot sequence
[root@localhost ~] awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.4.179-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-6d4c599606814867814f1a8eec7bfd1e) 7 (Core)
Set the boot sequence number
[root@localhost ~] grub2-set-default 0
Reboot
reboot
Check the kernel version
uname -r

图片 2

2. RPM installation

Check the kernel version
uname -r
1. Find the version
Because the ELRepo source is the latest version, the old version of the kernel can only be downloaded manually.
Find the historical version of kernel rpm:
http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/
2. You need to download three types of rpm
wget
http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt
devel-4.4.215-1.el7.elrepo.x86_64.rpm
wget
http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt
headers-4.4.215-1.el7.elrepo.x86_64.rpm
wget
http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt-
4.4.215-1.el7.elrepo.x86_64.rpm
3. Install the kernel
rpm -ivh kernel-lt-4.4.215-1.el7.elrepo.x86_64.rpm
rpm -ivh kernel-lt-devel-4.4.215-1.el7.elrepo.x86_64.rpm
or
#Install all in one click
rpm -Uvh *.rpm
4. Confirm the installed kernel version
[root@localhost ~]# rpm -qa | grep kernel
kernel-headers-3.10.0-1160.15.2.el7.x86_64
kernel-devel-3.10.0-1160.49.1.el7.x86_64
kernel-tools-libs-3.10.0-957.el7.x86_64
kernel-3.10.0-957.el7.x86_64
kernel-ml-4.9.9-1.el7.elrepo.x86_64
kernel-lt-4.4.215-1.el7.elrepo.x86_64
kernel-tools-3.10.0-957.el7.x86_64
kernel-lt-devel-4.4.215-1.el7.elrepo.x86_64

5. Set startup
Check the startup order
[root@localhost ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.4.215-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (4.9.9-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-b91f945269084aa98e8257311ee713c5) 7 (Core)
Set the boot order
[root@localhost ~]# grub2-set-default 0
Reboot to take effect
[root@localhost ~]# reboot

3. Source code installation

1. Install the core software package
yum install -y gcc make git ctags ncurses-devel openssl-devel
yum install -y bison flex elfutils-libelf-devel bc
2. Create a kernel compilation directory
Use the kernelbuild directory under home
mkdir ~/kernelbuild
3. Get the kernel source code
Tsinghua University mirror site:
https://mirror.tuna.tsinghua.edu.cn/kernel/v4.x/?C=M&O=D
Other source code installation package download address:
https://mirrors.edge.kernel.org/pub/linux/kernel/
linux-4.xx.xx.tar.xz
linux-4.xx.xx.tar.gz
Both formats are acceptable, tar.xz has a higher compression rate and a smaller file size.
Download online: wget https://mirror.tuna.tsinghua.edu.cn/kernel/v4.x/linux-4.17.11.tar.xz
4. Unzip the kernel code
After unzipping it, enter the source directory:
tar -xvJf linux-4.17.11.tar.xz
To ensure that the kernel tree is absolutely clean, enter the kernel directory and execute the make mrproper command:
cd linux-4.17.11
make clean && make mrproper

5. Kernel configuration
Copy the current kernel configuration file
config-3.10.0-862.el7.x86_64 is the kernel configuration file of my current environment, modify it according to the actual situation
cp /boot/config-3.10.0-862.el7.x86_64 .config
Advanced configuration
y is enabled, n is disabled, and m is enabled when needed.
make menuconfig: old ncurses interface, replaced by nconfig
make nconfig: New command line ncurses interface
6. Compile and install
Compile the kernel
If you have a quad-core machine, x can be 8
make -j x
Install the kernel
After compiling the kernel, install: Warning: From here on, you need root privileges to execute commands, otherwise it will fail.
make modules_install install
7. Set up startup
Check the startup sequence
[root@localhost ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.17.11-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (4.9.9-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-b91f945269084aa98e8257311ee713c5) 7 (Core)
Set boot order
[root@localhost ~]# grub2-set-default 0
Reboot to take effect
[root@localhost ~]# reboot


Related Products

01

LET'S TALK ABOUT YOUR PROJECTS

  • sinsmarttech@gmail.com
  • 3F, Block A, Future Research & Innovation Park, Yuhang District, Hangzhou, Zhejiang, China

Our experts will solve them in no time.