Modifying the start time of grub in Ubuntu

Time:2020-7-15

The starting time of grub query and modification is basically to modify / etc / default / grub

#Comment out grub_ HIDDEN_ TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT=0
#Modify grub_ TIMEOUT = 0 
GRUB_TIMEOUT = 0

Then runupdate-grubRebuild / boot / grub/ grub.cfg However, thisIt doesn’t workIt’s still 30 seconds to wait

View / 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 ###

As can be seen from the above configuration, the timeout is 30 seconds for LVM partitions and 30 seconds for EFI mode startup

Let’s take a look at / etc / grub.d/00, which generates this configuration_ Header script

...
    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
...

You can see that the timeout of 30 seconds is passedGRUB_RECORDFAIL_TIMEOUTThis value is set
So you just need to use / boot / grub/ grub.cfg Add or modifyGRUB_RECORDFAIL_TIMEOUT

GRUB_RECORDFAIL_TIMEOUT=0

Then runsudo update-grubRebuild / boot / grub/ grub.cfg That’s OK