1. View all kernel versions installed on the server
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (3.10.0-1160.83.1.el7.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.80.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)
3 : CentOS Linux (3.10.0-1160.83.1.el7.x86_64.debug) 7 (Core)
4 : CentOS Linux (3.10.0-1160.80.1.el7.x86_64.debug) 7 (Core)
5 : CentOS Linux (0-rescue-0e5781d77781441b97290d7bad5663e2) 7 (Core)
2. Modify version configuration
vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=3
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet intel_iommu=on iommu=pt"
GRUB_DISABLE_RECOVERY="true"
Change the value in the configuration file GRUB_DEFAULT
to the corresponding value ID viewed above, and modify it according to your own needs; if I want to change it here, I will modify CentOS Linux (3.10.0-1160.80.1.el7.x86_64) 7 (Core)
it to:
GRUB_DEFAULT=1
3. Compile configuration
grub2-mkconfig -o /boot/grub2/grub.cfg
4. Restart the system
After the compilation is completed, the system needs to be restarted to take effect
reboot
5. Check the kernel version after reboot
Wait for the restart to complete the command to view the current kernel version
uname -a
uname -r
Complete the version switch.