Install the kernel header

View version

View kernel version

Insert picture description here

View the version of the kernel header
Insert picture description here

Install the corresponding kernel header

Install the correct one from the repositorykernel-devel / linux-header

Through software repositories

  • Update software source
  • Install the kernel header

Update software source

[root@localhost ~]# yum install -y wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#或者,如果没有wget命令,则使用下面
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

Install the kernel header

 yum install kernel-devel-`uname -r`

Install the kernel header through the rpm package

If the corresponding kernel is not found in the yum software warehouse, you need to manually install the rpm

https://linuxsoft.cern.ch/cern/centos/7/updates/x86_64/repoview/kernel-devel.html

You can find the corresponding kernel header on this website.
After you find it, upload it to the centos server and install it using rpm

rpm -ivh kernel-devel-3.10.0-957.el7.x86_64.rpm

note

If you are prompted to install a higher version of the updated kernel header, you need to uninstall the higher version first

View the highest version

Insert picture description here

Unload kernel header

The 3.10-1160.6.1.el7.x86_64head here is the latest uninstall

rpm -ivh kernel-devel-3.10-1160.6.1.el7.x86_64.rpm

Install the kernel that needs to be installed

rpm -ivh kernel-devel-3.10.0-957.el7.x86_64.rpm

Special attention

The operation of uninstalling the kernel head is very serious and cannot be operated casually

Guess you like

Origin blog.csdn.net/qq_41861526/article/details/110230107