为什么赢了';grub是否立即启动到Ubuntu?

为什么赢了';grub是否立即启动到Ubuntu?,ubuntu,boot,grub,Ubuntu,Boot,Grub,我想直接启动我的Xubuntu。我在网上搜索了一下,发现可以编辑文件/etc/default/grub,使grub超时0秒。您需要做的是将GRUB\u TIMEOUT更改为0,然后在shell中运行sudo update GRUB。我这样做了,但重新启动系统后仍然有30秒的超时。在进一步调查之后,我找到了文件/boot/grub/grub.cfg,并找到了以下两行代码: if [ "${recordfail}" = 1 ] ; then set timeout=30 <--------

我想直接启动我的Xubuntu。我在网上搜索了一下,发现可以编辑文件
/etc/default/grub
,使grub超时0秒。您需要做的是将
GRUB\u TIMEOUT
更改为
0
,然后在shell中运行
sudo update GRUB
。我这样做了,但重新启动系统后仍然有30秒的超时。在进一步调查之后,我找到了文件
/boot/grub/grub.cfg
,并找到了以下两行代码:

if [ "${recordfail}" = 1 ] ; then
  set timeout=30 <-------------------------------!!
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=0
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=0
  fi
fi
if [ $grub_platform = efi ]; then
  set timeout=30 <-------------------------------!!
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
  fi
fi
如果[“${recordfail}”=1];然后

设置timeout=30我在shell中运行了
info-f grub
,在菜单中导航,发现grub有这个规则
grub\u RECORDFAIL\u timeout
。我将此规则添加到grub文件中,并将其设置为0,当我重新启动时,它不会花费30秒,而是更短的时间。需要10秒

在这之后,我决定再次阅读
/boot/grub/grub.cfg
文件,我发现了一些有趣的东西

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-4457-E741' {
    insmod part_gpt
    insmod fat
    set root='hd0,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  4457-E741
    else
      search --no-floppy --fs-uuid --set=root 4457-E741
    fi
    chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
  set timeout=10 <--------------------------------!!
fi
### END /etc/grub.d/30_os-prober ###
###BEGIN/etc/grub.d/30_os-prober###
菜单项“Windows启动管理器(on/dev/sda2)”--类窗口--类操作系统$菜单项\u id\u选项“osprober-efi-4457-E741”{
insmod部分gpt
insmod脂肪
设置root='hd0,gpt2'
如果[x$feature\u platform\u search\u hint=xy];则
搜索--无软盘--fs uuid--set=root--提示bios=hd0,gpt2--提示efi=hd0,gpt2--提示baremetal=ahci0,gpt2 4457-E741
其他的
搜索--无软盘--fs uuid--集=根4457-E741
fi
chainloader/efi/Microsoft/Boot/bootmgfw.efi
}
设置超时\u样式=菜单
如果[“${timeout}”=0];然后

设置超时=10 Hi Juan-这太棒了,谢谢!由于StackOverflow是一个问答网站,建议将您的答案添加为解决方案,而不是将其嵌入问题中。:)如果您的
/boot
目录位于btrfs或LVM上,您应该考虑另一个技巧(而不是禁用os prober)可能是使用
0.0
超时,因为它不等于
0
。在这篇文章中提到。