centos7.9多内核情况下手动指定启动内核
    文章作者:恒爱云[恒爱网络] 阅读次数:1404 发布时间:2025-1-13

    查看GRUB缺省启动顺序

     cat /etc/default/grub | grep GRUB_DEFAULT  回显:GRUB_DEFAULT=saved

    如果是saved,就是按照指定保存的内核启动,如果为数字(0/1/2等),就是/boot/grub2/grub.cfg中对应位置的内核,建议设置为saved。


    查看当前使用的内核:

     grub2-editenv list    回显:saved_entry=CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)  with debugging


    查看可以使用的内核:

     cat /boot/grub2/grub.cfg | grep 'menuentry '  回显:

    menuentry 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
    menuentry 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
    menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
    menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {


    手动设置默认启动的内核:

     grub2-set-default 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core) '

    查看设置后的结果:

     grub2-editenv list   回显: saved_entry=CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core)

    reboot 重启生效。