無法減少 Grub 啟動延遲

無法減少 Grub 啟動延遲

我有一台戴爾筆記型電腦,在單一 320GB 硬碟上運行單一作業系統 Ubuntu Mate 15.10 和 GRUB,分割區為/& /home。我想將預設的 grub 啟動延遲從 10 秒減少到“0”。到目前為止,我已經透過 Grub-Customizer 和直接編輯 嘗試了其他地方建議的以下調整,但沒有成功/etc/default/grub。其他線路未受干擾。更改後,我sudo update-grub每次都跑步。 Grub 啟動延遲不變,為 10 秒。

  • GRUB_TIMEOUT=”0”&GRUB_HIDDEN_TIMEOUT=”0”
  • GRUB_TIMEOUT=”0”&#GRUB_HIDDEN_TIMEOUT=”0”
  • GRUB_TIMEOUT=”0”&GRUB_HIDDEN_TIMEOUT=””
  • GRUB_TIMEOUT=”2”&GRUB_HIDDEN_TIMEOUT=”2”

請您建議解決這個問題。謝謝。

我的新程式碼(建議更改後)/boot/grub/grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="Ubuntu"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
function recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
else
  search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
else
  search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
fi
insmod gfxmenu
insmod png
set theme=($root)/boot/grub/themes/ubuntu-mate/theme.txt
export theme
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=hidden
    set timeout=0
  # Fallback hidden-timeout code in case the timeout_style feature is
  # unavailable.
  elif sleep --interruptible 0 ; then
    set timeout=0
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 60,59,55; then
  clear
fi

color_normal=light-gray/black

if [ -e ${prefix}/themes/ubuntu-mate/theme.txt ]; then
  insmod png
  theme=${prefix}/themes/ubuntu-mate/theme.txt
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
    set gfxpayload="${1}"
    if [ "${1}" = "keep" ]; then
        set vt_handoff=vt.handoff=7
    else
        set vt_handoff=
    fi
}
if [ "${recordfail}" != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-a2bdc1a5-f2fb-489d-adec-ba5a92514f0c' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    else
      search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    fi
    linux   /boot/vmlinuz-4.2.0-17-generic root=UUID=a2bdc1a5-f2fb-489d-adec-ba5a92514f0c ro  quiet splash $vt_handoff
    initrd  /boot/initrd.img-4.2.0-17-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-a2bdc1a5-f2fb-489d-adec-ba5a92514f0c' {
    menuentry 'Ubuntu, with Linux 4.2.0-17-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.2.0-17-generic-advanced-a2bdc1a5-f2fb-489d-adec-ba5a92514f0c' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
        else
          search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
        fi
        echo    'Loading Linux 4.2.0-17-generic ...'
        linux   /boot/vmlinuz-4.2.0-17-generic root=UUID=a2bdc1a5-f2fb-489d-adec-ba5a92514f0c ro  quiet splash $vt_handoff
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-4.2.0-17-generic
    }
    menuentry 'Ubuntu, with Linux 4.2.0-16-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.2.0-16-generic-advanced-a2bdc1a5-f2fb-489d-adec-ba5a92514f0c' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
        else
          search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
        fi
        echo    'Loading Linux 4.2.0-16-generic ...'
        linux   /boot/vmlinuz-4.2.0-16-generic root=UUID=a2bdc1a5-f2fb-489d-adec-ba5a92514f0c ro  quiet splash $vt_handoff
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-4.2.0-16-generic
    }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry 'Memory test (memtest86+)' {
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    else
      search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    fi
    knetbsd /boot/memtest86+.elf
}
menuentry 'Memory test (memtest86+, serial console 115200)' {
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    else
      search --no-floppy --fs-uuid --set=root a2bdc1a5-f2fb-489d-adec-ba5a92514f0c
    fi
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

答案1

Grub 忽略零逾時並設定為 10 秒

在您中,/etc/default/grub您正在傳遞值“0”。 Grub 會忽略零逾時並將該值重設為 10。為了「欺騙」Grub,傳遞值 0.0,當 Grub 測試時該值不等於 0。

將超時設為零

在我的中/etc/default/grub,我有這些相關的行設定:

#GRUB_DEFAULT=0 # Rather than option #1, we'll always default to last boot choice.
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_HIDDEN_TIMEOUT=0.0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0.0

我使用不帶雙引號的值0.0來反映數值的使用方式。

請注意,第一行已被註解掉。這意味著 grub 不再預設為第一個選單選項(在我的例子中為 Kernel 4.9.21),而是使用最後一個啟動選項(在我的例子中為 Kernel 4.4.0-72-generic)進階選項選單

第二行和第三行確保您始終啟動到上次選擇的相同選項。

未出現選單時更改啟動選項

更好的方法是減少逾時並提供強制選單顯示的選項。該方法的描述如下:如何隱藏 GRUB 選單,並讓 Shift 或 esc 鍵在啟動時顯示隱藏的 GRUB 選單

答案2

搜尋/boot/grub/grub.conf字串:

set timeout=10

如果找到它,周圍的線條可能會幫助您找出問題所在。

編者註:最好不要/boot/grub/grub.conf手動編輯,因為它會時不時地被自動覆蓋。

相關內容