on  It Road.com

解决方法

  1. 查看当前运行的内核版本
# uname -a
Linux geeklab 3.8.13-94.el7uek.x86_64 #2 SMP Wed Nov 11 14:18:22 PST 2015 x86_64 x86_64 x86_64 GNU/Linux
  1. 按照 GRUB2 文件列出内核条目:
# awk -F\' '=="menuentry " {print }' /etc/grub2.cfg
Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-94.el7uek.x86_64
Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-94.el7uek.x86_64 with debugging
Oracle Linux Server 7.1, with Linux 3.10.0-229.el7.x86_64
Oracle Linux Server 7.1, with Unbreakable Enterprise Kernel 3.8.13-55.1.6.el7uek.x86_64
Oracle Linux Server 7.1, with Linux 0-rescue-441e86c9ff854310a306bd33e56aae2b

注意:第一个条目表示为零。
因此,当前服务器根据上述 uname -a命令输出启动到第 0 个条目。

  1. 让我们将内核版本修改为 3.8.13-55.1.6.el7uek.x86_64,它位于第 4 行,但表示为条目 3.
# grub2-set-default 3
  1. 对 /etc/default/grub 的更改需要重新构建 grub.cfg 文件,如下所示:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.8.13-94.el7uek.x86_64
Found initrd image: /boot/initramfs-3.8.13-94.el7uek.x86_64.img
Found linux image: /boot/vmlinuz-3.8.13-55.1.6.el7uek.x86_64
Found initrd image: /boot/initramfs-3.8.13-55.1.6.el7uek.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-441e86c9ff854310a306bd33e56aae2b
Found initrd image: /boot/initramfs-0-rescue-441e86c9ff854310a306bd33e56aae2b.img
done

重新启动服务器,它将以内核版本 3.8.13-55.1.6.el7uek.x86_64 启动。

# shutdown -r now
CentOS/RHEL/OEL 7如何更改默认内核(使用旧内核启动)

问题:

如何修改 GRUB2 默认条目以启动不同的内核版本?

日期:2020-09-17 00:12:22 来源:oir作者:oir