2

网上查询修改grub的启动时间基本上是修改 /etc/default/grub

#注释掉GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT=0
#修改GRUB_TIMEOUT = 0 
GRUB_TIMEOUT = 0

然后运行update-grub重新生成/boot/grub/grub.cfg.然而这并不管用,依旧要等待30秒

查看/boot/grub/grub.cfg

### BEGIN /etc/grub.d/00_header ###
...
function recordfail {
  set recordfail=1
  # GRUB lacks write support for lvm, so recordfail support is disabled.
}
...
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
...
if [ $grub_platform = efi ]; then
  set timeout=30
...
### END /etc/grub.d/00_header ###

从上面的配置可以看到,如果是lvm分区,则超时时间为30秒;如果是EFI方式启动的超时时间为30秒.优先级EFI > LVM.

再看下生成这段配置的/etc/grub.d/00_header脚本

...
    cat << EOF
if [ "\${recordfail}" = 1 ] ; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
else
EOF
...
if [ "$recordfail_broken" = 1 ]; then
  cat << EOF
if [ \$grub_platform = efi ]; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
  if [ x\$feature_timeout_style = xy ] ; then
    set timeout_style=menu
  fi
...

可以看到这超时30秒是通过GRUB_RECORDFAIL_TIMEOUT这个值设置的.
所以只需要在 /boot/grub/grub.cfg 加上或修改 GRUB_RECORDFAIL_TIMEOUT

GRUB_RECORDFAIL_TIMEOUT=0

然后运行sudo update-grub重新生成/boot/grub/grub.cfg即可.


nicechao
9 声望0 粉丝