想要隐藏 Grub 菜单

想要隐藏 Grub 菜单

首先,抱歉,我的英语不好(我是法国人)!!

我刚刚购买了一台戴尔 Inspiron 13 二合一笔记本电脑,安装了 Kubuntu 21.10(无双启动),但在 GRUB 方面遇到了一点问题!

grub 菜单在启动时仍然可见,并有 30 秒倒计时......

我首先尝试使用 Grub 定制器更改配置,但没有结果。

然后我手动修改了 /etc/default/grub,再加上 sudo update-grub,没有结果。

我也尝试过本页中有关 os_prober 的解释:https://gist.github.com/LeahCim/9332432但仍然没有结果...

实际上,我的 /etc/default/grub 是

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_DISABLE_OS_PROBER=true
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE="640x480"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

问候

编辑 :

根据这里的建议,我将 GRUB_HIDDEN_TIMEOUT_QUIET= 从 false 更改为 true,但效果并不好。即使将 GRUB_HIDDEN_TIMEOUT= 从 2 更改为 0 也没有任何变化。

事实上,无论我在 /etc/default/grub 中做了什么更改,似乎对 Grub 都没有影响;就好像 GRUB 不关心 /boot/grub/grub.cfg,或者 grub.cfg 不关心 /etc/default/grub,即使在“sudo update-grub”之后也是如此。

编辑2:

无论我怎么尝试,都没有任何变化……我尝试在 grub.cfg 中找到一些东西,但这对我来说太难了。我看到了“timeout=30”(第 109 行),它对应于 30 秒倒计时,但我不知道该怎么做,也不知道该如何更改它。你能帮帮我吗?!!这是文件:

#
# 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 [ "${initrdfail}" = 2 ]; then
   set initrdfail=
elif [ "${initrdfail}" = 1 ]; then
   set next_entry="${prev_entry}"
   set prev_entry=
   save_env prev_entry
   if [ "${next_entry}" ]; then
      set initrdfail=2
   fi
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
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 initrdfail {
    if [ -n "${have_grubenv}" ]; then if [ -n "${partuuid}" ]; then
      if [ -z "${initrdfail}" ]; then
        set initrdfail=1
        if [ -n "${boot_once}" ]; then
          set prev_entry="${default}"
          save_env prev_entry
        fi
      fi
      save_env initrdfail
    fi; fi
}
function recordfail {
  set recordfail=1
  # GRUB lacks write support for lvm, so recordfail support is disabled.
}
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_gpt
insmod lvm
insmod ext2
set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
else
  search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
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=fr_FR
  insmod gettext
fi
terminal_output gfxterm
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
if [ $grub_platform = efi ]; then
  set timeout=30
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
  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
#set_background_image "images/tile.png";

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 0,0,0; then
  clear
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-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_gpt
    insmod lvm
    insmod ext2
    set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
    else
      search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
    fi
    linux   /boot/vmlinuz-5.13.0-21-generic root=/dev/mapper/vgkubuntu-root ro  quiet splash $vt_handoff
    initrd  /boot/initrd.img-5.13.0-21-generic
}
submenu 'Options avancées pour Ubuntu' $menuentry_id_option 'gnulinux-advanced-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
    menuentry 'Ubuntu, avec Linux 5.13.0-21-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-21-generic-advanced-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-21-generic…'
        linux   /boot/vmlinuz-5.13.0-21-generic root=/dev/mapper/vgkubuntu-root ro  quiet splash $vt_handoff
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-21-generic
    }
    menuentry 'Ubuntu, avec Linux 5.13.0-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-21-generic-recovery-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-21-generic…'
        linux   /boot/vmlinuz-5.13.0-21-generic root=/dev/mapper/vgkubuntu-root ro recovery nomodeset dis_ucode_ldr 
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-21-generic
    }
    menuentry 'Ubuntu, avec Linux 5.13.0-20-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-20-generic-advanced-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-20-generic…'
        linux   /boot/vmlinuz-5.13.0-20-generic root=/dev/mapper/vgkubuntu-root ro  quiet splash $vt_handoff
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-20-generic
    }
    menuentry 'Ubuntu, avec Linux 5.13.0-20-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-20-generic-recovery-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-20-generic…'
        linux   /boot/vmlinuz-5.13.0-20-generic root=/dev/mapper/vgkubuntu-root ro recovery nomodeset dis_ucode_ldr 
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-20-generic
    }
    menuentry 'Ubuntu, avec Linux 5.13.0-19-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-19-generic-advanced-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-19-generic…'
        linux   /boot/vmlinuz-5.13.0-19-generic root=/dev/mapper/vgkubuntu-root ro  quiet splash $vt_handoff
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-19-generic
    }
    menuentry 'Ubuntu, avec Linux 5.13.0-19-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.13.0-19-generic-recovery-5a9194c9-d3ba-4f02-925e-a6bf54b49c06' {
        recordfail
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod lvm
        insmod ext2
        set root='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/WJ7HiC-1808-IY8B-ZnJg-m2JO-X2Sp-eon3xJ/0mBBLm-PWoV-07pO-6ItQ-H0vK-80Oc-7ctcrG'  5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        else
          search --no-floppy --fs-uuid --set=root 5a9194c9-d3ba-4f02-925e-a6bf54b49c06
        fi
        echo    'Chargement de Linux 5.13.0-19-generic…'
        linux   /boot/vmlinuz-5.13.0-19-generic root=/dev/mapper/vgkubuntu-root ro recovery nomodeset dis_ucode_ldr 
        echo    'Chargement du disque mémoire initial…'
        initrd  /boot/initrd.img-5.13.0-19-generic
    }
}

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

### BEGIN /etc/grub.d/10_linux_zfs ###
### END /etc/grub.d/10_linux_zfs ###

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

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

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/25_pre-os-prober ###
set timeout_bak=${timeout}
set timeout_style_bak=${timeout_style}
### END /etc/grub.d/25_pre-os-prober ###

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

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
    fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/35_post-os-prober ###
set timeout=${timeout_bak}
set timeout_style=${timeout_style_bak}
### END /etc/grub.d/35_post-os-prober ###

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

我在 KDE 分区管理器中注意到我的 NVME 驱动器出现了 2 次:第一次是 /dev/nvme0n1(有 2 个分区:/dev/nvme0n1p1 安装在 /boot/efi 512Mio FAT32 上,/dev/nvme0n1p2 安装在 vgkubuntu 476,44Gio LVM2 PV 上)和第二次 /dev/vgkubuntu(有 2 个分区:/dev/vgkubuntu/root 安装在 / 475,48Gio EXT4 上,/dev/vgkubuntu/swap_1 980Mio linuxswap 上)。这是正常的吗?这能解释我的 GRUB 问题吗?

答案1

我相信你需要改变

GRUB_HIDDEN_TIMEOUT=2

GRUB_HIDDEN_TIMEOUT=0

您还需要sudo update-grub在对配置文件进行更改后运行。

您绝对不需要 GRUB 定制器。在我看来,GRUB 定制器是一种祸害:大多数人都希望启动尽可能安全和稳定。将不太稳定、不太安全、花哨的东西安装到一个只能看到几秒钟的基本低级实用程序上有点愚蠢。但 Linux 最好的一点是,您有很多选择,包括不太好的选择。用配置隐藏 GRUB 绝对是更好的选择。

相关内容