grub2更改默认启动项

grub2更改默认启动项

grub2 和 grub0.97 的启动项目差别还是比较大的,最近Ubuntu自动更新,把默认启动项目给更改了,导致很多驱动无法成功加载,需要改回去,这里记录下修改过程:

通过sudo vim /boot/grub/grub.cfg打开grub2的默认配置文件

注意:

  • grub2的一级和二级 menu 的索引都是从 0 开始的
  • 假如第一个启动项(索引为0)不包含子menu,可以通过修改配置set default="0"把默认启动项设为第一个
  • 如果一个启动项包含子menu,可以通过set default="1> 3"的形式来设置默认启动项,其中1是一级menu的索引,2是二级menu的索引

If you have a submenu in your grub.cfg you should use two digits like this:

grub-reboot '1>3'
The first is menu index, and the second is submenu index.

For example, to boot last entry from config like this:

grep menu /boot/grub/grub.cfg

menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 4.6.0-0.bpo.1-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.6.0-0.bpo.1-amd64-advanced-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 4.6.0-0.bpo.1-amd64 (sysvinit)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.6.0-0.bpo.1-amd64-init-sysvinit-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 4.6.0-0.bpo.1-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.6.0-0.bpo.1-amd64-recovery-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-amd64-advanced-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-amd64 (sysvinit)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-amd64-init-sysvinit-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
    menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-4-amd64-recovery-1ffa16a9-fda2-43b5-91b9-c91a08ff190f' {
you should use:

grub-reboot '1>5'
and reboot.

参考链接

How to correctly set up the right GRUB 2 default menu entry?

推荐这些文章:

CentOS7修改默认启动内核

查看可用内核
# grep "menuentry" /boot/grub2/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_op...

ubuntu 切换linux内核

运行命令查看已安装内核:

dpkg --get-selections |grep linux-image

  显示如下:

linux-image-5.4.0-81-generic install
linux-image-5.4.0-99-generic ...

Linux 系统操作篇

1、配置网卡 ifconfig
问题1:第一块网卡名称 etho网卡名称受biosdevname和net.iframes两个参数影响

网卡名称
biosdevname
net.iframes

etho
0
0

ens33 
0
1

em1
1
1

    
 
&...

文章标题:grub2更改默认启动项
文章链接:https://www.dianjilingqu.com/50977.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。
THE END
< <上一篇
下一篇>>