debian12 多个GRUB内核情况下手动调整默认的启动内核
    文章作者:恒爱云[恒爱网络] 阅读次数:2232 发布时间:2025-1-13

    某用户的debian12系统突然无法联网了,开机会显示加载网卡失败 。因此联系我们给于协助!


    开机后,发现grub菜单里显示的顺序,默认自上而下默认第一个是名为 Debian GNU/Linux, with Linux 6.1.0-18-amd64 1的系统,按自上而下的顺序排在第一,那数字应为0 ,使用 ps -p 1 -o comm=  查看运行模式 ,发现是用了 init 单用户模式,所以导致了无法加载eth0网卡的问题。

    而排在第二的是  Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)这个才是系统权限的内核, 那么顺序应为 1 


    本次的任务就是将默认启动号为0 的内核,改成 默认为1 ,进而让系统开机自动进入  Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)  

    首先根据网上一些教程vi /boot/grub/grub.cfg  修改 set default="0" 为GRUB顺序里显示的

     

    vi /etc/default/grub   修改 GRUB_DEFAULT =0 为 grub菜单里显示的顺序,默认自上而下是 0 开始,systemd 在顺序1 所以改成  GRUB_DEFAULT = 1  最后执行更新  update-grub 后再 reboot重启 没效果,还是进入默认第一个内核 init 单用户模式。

    将  RUB_DEFAULT = 1 改成具体的内核版本名称  RUB_DEFAULT = "Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)"   最后执行更新  update-grub  又报错:

    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-6.1.0-18-amd64
    Found initrd image: /boot/initrd.img-6.1.0-18-amd64
    Warning: Please don't use old title `Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)' for GRUB_DEFAULT, use `Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)' (for versions before 2.00) or `gnulinux-advanced-a5105199-637a-428a-99e2-2c6992e19fd6>gnulinux-6.1.0-18-amd64-init-systemd-a5105199-637a-428a-99e2-2c6992e19fd6' (for 2.00 or later)
    Found linux image: /boot/vmlinuz-5.10.0-28-amd64
    Found initrd image: /boot/initrd.img-5.10.0-28-amd64
    Found linux image: /boot/vmlinuz-5.10.0-8-amd64
    Found initrd image: /boot/initrd.img-5.10.0-8-amd64
    Warning: os-prober will not be executed to detect other bootable partitions.
    Systems on them will not be added to the GRUB boot configuration.
    Check GRUB_DISABLE_OS_PROBER documentation entry.

    根据错误先查一下内核版本是大于2.00还是小于,使用命令:dpkg -l|grep grub|grep ii   发现都是大于2.00 所以最后将  


    RUB_DEFAULT = "Debian GNU/Linux, with Linux 6.1.0-18-amd64 (systemd)

    改为 

    RUB_DEFAULT = "gnulinux-advanced-a5105199-637a-428a-99e2-2c6992e19fd6>gnulinux-6.1.0-18-amd64-init-systemd-a5105199-637a-428a-99e2-2c6992e19fd6


     保存后,最后执行更新  update-grub  后提示:

    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-6.1.0-18-amd64
    Found initrd image: /boot/initrd.img-6.1.0-18-amd64
    Found linux image: /boot/vmlinuz-5.10.0-28-amd64
    Found initrd image: /boot/initrd.img-5.10.0-28-amd64
    Found linux image: /boot/vmlinuz-5.10.0-8-amd64
    Found initrd image: /boot/initrd.img-5.10.0-8-amd64
    Warning: os-prober will not be executed to detect other bootable partitions.
    Systems on them will not be added to the GRUB boot configuration.
    Check GRUB_DISABLE_OS_PROBER documentation entry.
    done


    应该是没有问题了,最后 reboot 后发现已经按指定的内核默认启动了。