一 场景
需要保留新内核的情况下使操作系统在下次启动默认加载的是旧内核。
二 系统基本信息
1.系统版本
[root@localhost ~]# nkvers ############## Kylin Linux Version #################Release:Kylin Linux Advanced Server release V10 (Tercel)Kernel:4.19.90-23.20.v2101.ky10.x86_64Build:Kylin Linux Advanced Serverrelease V10 (SP1) /(Tercel)-x86_64-Build20/20210518#################################################
2.内核版本(用23.8和23.20版本进行演示)
[root@localhost ~]# rpm -qa | grep kernel-[0-9]kernel-4.19.90-23.8.v2101.ky10.x86_64kernel-4.19.90-23.20.v2101.ky10.x86_64
三 具体修改步骤
1.查看系统里面的所有引导项
1.1 UEFI传统的Legacy BIOS启动 grub引导文件路径不一致,先需要查看系统是UEFI启动还是传统的Legacy BIOS启动
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOSUEFI#如果输出是UEFI则表示是UEFI启动#如果输出是BIOS则表示是传统的Legacy BIOS启动#UEFI启动#awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/efi/EFI/kylin/grub.cfg #传统的Legacy BIOS启动#awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg 下面示例是UEFI启动执行的命令输出[root@localhost ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/efi/EFI/kylin/grub.cfg 0 : Kylin Linux Advanced Server (4.19.90-23.20.v2101.ky10.x86_64) V10 (Tercel)1 : Kylin Linux Advanced Server (4.19.90-23.8.v2101.ky10.x86_64) V10 (Tercel)2 : Kylin Linux Advanced Server (0-rescue-457bd31702164eff81c4d8a412dedc10) V10 (Tercel)3 : System setup
2.查看当前的内核版本
[root@localhost ~]# uname -r4.19.90-23.20.v2101.ky10.x86_64
3.查看系统开机加载的引导项
[root@localhost ~]# grub2-editenv listsaved_entry=Kylin Linux Advanced Server (4.19.90-23.20.v2101.ky10.x86_64) V10 (Tercel)boot_success=0
4.修改开机默认加载23.8内核
[root@localhost ~]# grub2-set-default "Kylin Linux Advanced Server (4.19.90-23.8.v2101.ky10.x86_64) V10 (Tercel)"[root@localhost ~]# [root@localhost ~]# grub2-editenv listsaved_entry=Kylin Linux Advanced Server (4.19.90-23.8.v2101.ky10.x86_64) V10 (Tercel)boot_success=0
5. 重启验证即可。
来源地址:https://blog.csdn.net/weixin_45754407/article/details/131431725