查看当前内核版本
下载内核地址
https://mirrors.aliyun.com/elrepo/kerne
l/el7/x86_64/RPMS
安装内核 rpm -ivh kernel-lt-* --nodeps --force
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg (提示找不到/etc/grub2.cfg 需要重启一下系统)
输出:
0 : CentOS Linux (4.4.222-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-beb5a720b4464373968186d773e35ac5) 7 (Core)
重新生成grub配置文件
grub2-mkconfig -o /boot/grub2/grub.cfg
---输出类似如下: Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.214-1.el7.elrepo.x86_64 Found initrd image: /boot/initramfs-5.4.214-1.el7.elrepo.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-13fa607805964427bb4a2297f3619e6e Found initrd image: /boot/initramfs-0-rescue-13fa607805964427bb4a2297f3619e6e.img done
输入grub2-editenv list命令查看默认启动项
grub2-editenv list
saved_entry=CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)
输入grub2-set-default命令修改默认启动项 (参照awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg 输出的列表序号 0是4.4.222 1是3.10.0-1062.el7.x86_64)
grub2-set-default 0
再次查看默认启动项,发现默认启动项已经改成了0
[root@bogon ~]# grub2-editenv list
saved_entry=0
重启 reboot