参考:https://docs.shanhe.com/v6.1/compute/vm/best-practices/linux/kernel_upgrade/
需求:内核版本3.10.0 ==> 4.18.0
操作步骤
1、查看当前内核版本
uname -r
uname -a
cat /etc/redhat-release
rpm -qa | grep kernel # 查看系统中全部的内核
2、升级内核
a、更新yum源: yum -y update
b、启用 ELRepo 仓库
ELRepo 仓库是基于社区的用于企业级 Linux 仓库,提供对 RedHat Enterprise(RHEL)和其他基于 RHEL 的 Linux 发行版(CentOS、Scientific、Fedora 等)的支持。
c、ELRepo仓库的公共密钥:rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
d、安装 ELRepo 仓库的 yum 源:rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
3、查看可用的系统内核包
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
4、安装最新版本内核
yum --enablerepo=elrepo-kernel install kernel-ml # 因为没有yum 源,所以没有安装包成功。
==============================================================
以上方法行不通,切不能达到我们需要的版本。
参考:https://developer.aliyun.com/article/1544782
https://blog.csdn.net/qq_40493944/article/details/143919397
如下,
一、下载centos内核rpm安装包
内核下载地址:https://dl.lamp.sh/kernel/el7/
http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS
下载如下3个rpm包
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-4.18.0-1.el7.elrepo.x86_64.rpm
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-4.18.0-1.el7.elrepo.x86_64.rpm
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-headers-4.18.0-1.el7.elrepo.x86_64.rpm
二、安装RPM包
yum install -y kernel-ml-4.18.0-1.el7.elrepo.x86_64.rpm kernel-ml-devel-4.18.0-1.el7.elrepo.x86_64.rpm kernel-ml-headers-4.18.0-1.el7.elrepo.x86_64.rpm
安装完毕后查看系统可用启动内核
awk -F \' '$1=="menuentry " {print i++" : " $2}' /etc/grub2.cfg
[root@localhost opt]# awk -F \' '$1=="menuentry " {print i++" : " $2}' /etc/grub2.cfg
0 : CentOS Linux (4.18.0-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.71.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-eb185a05692d4549b66325167df504ad) 7 (Core)
三、使用新内核
grub2-set-default "CentOS Linux (6.9.10-1.el7.x86_64) 7 (Core)"
四、重启 (这里重启有问题,看后面的解答)
reboot
五、查看内核版本
uname -r
[root@localhost ~]# uname -sr Linux 4.18.0-1.el7.elrepo.x86_64 [root@localhost ~]# awk -F \' '$1=="menuentry " {print i++" : " $2}' /etc/grub2.cfg 0 : CentOS Linux (4.18.0-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (3.10.0-1160.71.1.el7.x86_64) 7 (Core) 2 : CentOS Linux (0-rescue-eb185a05692d4549b66325167df504ad) 7 (Core) [root@localhost ~]# rpm -qa | grep kernel kernel-ml-devel-4.18.0-1.el7.elrepo.x86_64 kernel-ml-headers-4.18.0-1.el7.elrepo.x86_64 kernel-3.10.0-1160.71.1.el7.x86_64 kernel-tools-3.10.0-1160.71.1.el7.x86_64 kernel-ml-4.18.0-1.el7.elrepo.x86_64 kernel-tools-libs-3.10.0-1160.71.1.el7.x86_64
六、更新软件
yum -y update
问题:
问题:重启后,VMware报错:客户机操作系统已禁用 CPU。请关闭或重置虚拟机。
解决参考:https://developer.aliyun.com/article/1548172
关机状态下执行,找到配置文件E:\vms\contOS7\CentOS7.vmx,末尾添加如下配置。
cpuid.0.eax = "0000:0000:0000:0000:0000:0000:0000:1011"
cpuid.0.ebx = "0111:0101:0110:1110:0110:0101:0100:0111"
cpuid.0.ecx = "0110:1100:0110:0101:0111:0100:0110:1110"
cpuid.0.edx = "0100:1001:0110:0101:0110:1110:0110:1001"
cpuid.1.eax = "0000:0000:0000:0001:0000:0110:0111:0001"
cpuid.1.ebx = "0000:0010:0000:0001:0000:1000:0000:0000"
cpuid.1.ecx = "1000:0010:1001:1000:0010:0010:0000:0011"
cpuid.1.edx = "0000:0111:1000:1011:1111:1011:1111:1111"
usb:0.present = "TRUE"
usb:0.deviceType = "hid"
usb:0.port = "0"
usb:0.parent = "-1"
保存后,重启虚拟机,正常启动后,查看linux内核版本。