CentOS8 or Rocky8 改變開機 Kernel

先列出目前有的 kernels

[root@liho ~]# grubby --info=ALL | grep ^kernel
kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64"
kernel="/boot/vmlinuz-4.18.0-348.el8.0.2.x86_64"
kernel="/boot/vmlinuz-0-rescue-8fd26ee222da4c8db77a2a79508176f6"

也列出目前使用的 kernel

[root@liho ~]# uname -r
4.18.0-372.9.1.el8.x86_64

取得更多 kernel 的資訊

[root@liho ~]# grubby --info="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64"
index=0
kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64"
args="ro console=tty0 crashkernel=auto resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap nomodeset biosdevname=0 net.ifnames=0 console=ttyS1,115200 $tuned_params"
root="/dev/mapper/rl-root"
initrd="/boot/initramfs-4.18.0-372.9.1.el8.x86_64.img $tuned_initrd"
title="Rocky Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Green Obsidian)"
id="8fd26ee222da4c8db77a2a79508176f6-4.18.0-372.9.1.el8.x86_64"

檢查目前 kernel 開機的版本

[root@liho ~]# grubby --grub2 --default-title
Rocky Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Green Obsidian)

[root@liho ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64

[root@liho ~]# grubby --default-index
0

指定想要更換 kernel 開機版本

[root@liho ~]# grubby --set-default "/boot/vmlinuz-4.18.0-348.el8.0.2.x86_64"
The default is /boot/loader/entries/6ec8a93f948e4e3e8741a179881b4a20-4.18.0-348.el8.0.2.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-348.el8.0.2.x86_64

[root@liho ~]# reboot

驗證

[root@kawas sandbox]# grubby --info /boot/vmlinuz-4.18.0-348.el8.0.2.x86_64
index=1
kernel="/boot/vmlinuz-4.18.0-348.el8.0.2.x86_64"
args="ro console=tty0 crashkernel=auto resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap nomodeset biosdevname=0 net.ifnames=0 console=ttyS1,115200 $tuned_params"
root="/dev/mapper/rl-root"
initrd="/boot/initramfs-4.18.0-348.el8.0.2.x86_64.img $tuned_initrd"
title="Rocky Linux (4.18.0-348.el8.0.2.x86_64) 8.5 (Green Obsidian)"
id="6ec8a93f948e4e3e8741a179881b4a20-4.18.0-348.el8.0.2.x86_64"