查看當(dāng)前內(nèi)核版本

下載內(nèi)核地址
https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS

安裝內(nèi)核 rpm -ivh kernel-lt-* --nodeps --force

awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg (提示找不到/etc/grub2.cfg 需要重啟一下系統(tǒng))
輸出:
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命令查看默認(rèn)啟動項
grub2-editenv list
saved_entry=CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)
輸入grub2-set-default命令修改默認(rèn)啟動項 (參照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
再次查看默認(rèn)啟動項,發(fā)現(xiàn)默認(rèn)啟動項已經(jīng)改成了0
[root@bogon ~]# grub2-editenv list
saved_entry=0
重啟 reboot
浙公網(wǎng)安備 33010602011771號