系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
-
NetDreamer
- 帖子: 858
- 注册时间: 2007-10-19 20:40
-
联系:
#1
帖子
由 NetDreamer » 2016-03-31 14:01
我的电脑使用了 UEFI 单一模式启动,安装了 Windows 和 Ubuntu 双启动。我喜欢由 BIOS 里的 Boot Manager 管理启动——开机按下 F10,选择启动 Windows 或 Ubuntu。但是,GRUB 好像有这样一个特性:只要探测到有其他操作系统,它会强制显示启动菜单。这样,我在 BIOS 里选择启动 Ubuntu,GRUB 还是会显示启动菜单——多了这么一层,很麻烦。
我认真学习了
https://help.ubuntu.com/community/Grub2/Setup这篇文章,然后修改 /etc/default/grub 文件中 GRUB_TIMEOUT=0,新增了一行 GRUB_DISABLE_OS_PROBER=true,这样就实现了我的目标。
# 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_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_DISABLE_OS_PROBER=true
我想请教一下,上述 grub 文件可以吗,有什么不对的地方没有。
Live and let live.
-
vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
-
联系:
#2
帖子
由 vickycq » 2016-03-31 14:09
NetDreamer 写了:新增了一行 GRUB_DISABLE_OS_PROBER=true,这样就实现了我的目标。
GRUB_DISABLE_OS_PROBER 是控制 grub-mkconfig(update-grub) 的,
和显示菜单没关系。
禁用 os-prober 后,运行 update-grub 时无法自动探测其它操作系统
‘GRUB_DISABLE_OS_PROBER’
Normally, grub-mkconfig will try to use the external os-prober program, if installed, to discover other operating systems installed on the same system and generate appropriate menu entries for them. Set this option to ‘true’ to disable this.
隐藏菜单主要靠以下三个参数
‘GRUB_TIMEOUT’
Boot the default entry this many seconds after the menu is displayed, unless a key is pressed. The default is ‘5’. Set to ‘0’ to boot immediately without displaying the menu, or to ‘-1’ to wait indefinitely.
‘GRUB_HIDDEN_TIMEOUT’
Wait this many seconds for a key to be pressed before displaying the menu. If no key is pressed during that time, display the menu for the number of seconds specified in GRUB_TIMEOUT before booting the default entry. We expect that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set to ‘0’ so that the menu is not displayed at all unless a key is pressed. Unset by default.
‘GRUB_HIDDEN_TIMEOUT_QUIET’
In conjunction with ‘GRUB_HIDDEN_TIMEOUT’, set this to ‘true’ to suppress the verbose countdown while waiting for a key to be pressed before displaying the menu. Unset by default.
参考
http://www.gnu.org/software/grub/manual/grub.html
上次由
vickycq 在 2016-03-31 17:36,总共编辑 1 次。
-
NetDreamer
- 帖子: 858
- 注册时间: 2007-10-19 20:40
-
联系:
#3
帖子
由 NetDreamer » 2016-03-31 14:18
vickycq 写了:
隐藏菜单主要靠以下三个参数
以前,我试过修改 GRUB_TIMEOUT=0,在双系统情况下,修改为 0 ,GRUB 的菜单仍然会倒计时 10 秒。最短只能修改为 1。我记得有篇文章说只要 GRUB 探测到其他操作系统的存在,它会强制显示 启动菜单。基于这一考虑,所以尝试了禁用其他 OS 的探测,那个菜单真的不显示了。
只不过,GRUB_TIMEOUT=0 这个选项,不知道是否起作用,因为现在我发现,虽然菜单不显示了,但是启动时屏幕两次变黑。
Live and let live.
-
vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
-
联系:
#4
帖子
由 vickycq » 2016-03-31 14:26
NetDreamer 写了:
以前,我试过修改 GRUB_TIMEOUT=0,在双系统情况下,修改为 0 ,GRUB 的菜单仍然会倒计时 10 秒。最短只能修改为 1。我记得有篇文章说只要 GRUB 探测到其他操作系统的存在,它会强制显示 启动菜单。基于这一考虑,所以尝试了禁用其他 OS 的探测,那个菜单真的不显示了。
只不过,GRUB_TIMEOUT=0 这个选项,不知道是否起作用,因为现在我发现,虽然菜单不显示了,但是启动时屏幕两次变黑。
关键是 GRUB_HIDDEN_TIMEOUT 和 GRUB_HIDDEN_TIMEOUT_QUIET
GRUB_HIDDEN_TIMEOUT
We expect that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set to ‘0’ so that the menu is not displayed at all unless a key is pressed.
‘GRUB_HIDDEN_TIMEOUT_QUIET’
In conjunction with ‘GRUB_HIDDEN_TIMEOUT’, set this to ‘true’ to suppress the verbose countdown while waiting for a key to be pressed before displaying the menu.
-
NetDreamer
- 帖子: 858
- 注册时间: 2007-10-19 20:40
-
联系:
#5
帖子
由 NetDreamer » 2016-03-31 14:36
我注释掉了 GRUB_DISABLE_OS_PROBER=true 那一行,update-grub,重新启动,GRUB 的菜单又回来了,倒计时 10 秒。
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
除了注释掉 PROBER 那一行,grub 文件中的其他的都没变。
Live and let live.
-
vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
-
联系:
#6
帖子
由 vickycq » 2016-03-31 15:39
-
NetDreamer
- 帖子: 858
- 注册时间: 2007-10-19 20:40
-
联系:
#8
帖子
由 NetDreamer » 2016-03-31 16:40
poloshiao 写了:討論這個問題
我感觉在双启动下,GRUB 菜单的隐藏,首要由是否探测到其他OS 的存在为前提,但是相关文档并没有强调这一点。
Live and let live.
-
vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
-
联系:
#10
帖子
由 vickycq » 2016-03-31 17:40
感谢指正。

难道 os-prober 的这个问题是 ubuntu-specific?我也有双系统的机器 但测试不到这个行为。
代码: 全选
adjust_timeout () {
if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
set timeout=10
fi
EOF
fi
}
这样看来,修改 os-prober 脚本开头的 quick_boot 为 0 即可
-
poloshiao
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
#11
帖子
由 poloshiao » 2016-03-31 20:30
禁止 GRUB 显示菜单。
1. 試試
1-1. /etc/default/grub
GRUB_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT=0
其它不改
1-2. sudo update-grub
1-3. sudo systemctl reboot
3. 進一步參閱
3-1.
http://askubuntu.com/a/157940
How do I skip the Grub menu on a dual-boot system?
3-2.
http://askubuntu.com/questions/18775/ho ... -boot-menu
How to remove or hide the GRUB boot menu?
4. 補充
4-1. Grub 2 (2.0.2 Beta) 版本
如果你設定
GRUB_TIMEOUT
<>0
GRUB_HIDDEN_TIMEOUT=0
執行 sudo update-grub 時 會出現 不支持 的錯誤訊息
4-2. 如果你希望保留一個 可以按下 esc 鍵 或 shift 鍵 以 強制顯示 grub 2 的機會
例如 等你
5 秒鐘
把 GRUB_HIDDEN_TIMEOUT=
5