1) 确保安装了grub2
1 | $ sudo apt-get install grub2
|
2) 修改/etc/default/grub文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # 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= #本项留空 GRUB_HIDDEN_TIMEOUT_QUIET= #本项留空 GRUB_TIMEOUT=10 #grub菜单显示的秒数 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=1280x1024 # 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" |
3) 修改/etc/grub.d/30_os-prober文件
1 | $ sudo vim /etc/grub.d/30_os-prober
|
将下面三处的timeout都修改为和/etc/default/grub中的timeout一致,比如timeout=10。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | make_timeout () { if [ "x${found_other_os}" = "x" ] ; then if [ "x${1}" != "x" ] ; then if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then verbose= else verbose=" --verbose" fi if [ "x${1}" = "x0" ] ; then cat <<EOF if [ "x\${timeout}" != "x-1" ]; then if keystatus; then if keystatus --shift; then set timeout=-1 else set timeout=10 #第一处 fi else if sleep$verbose --interruptible 3 ; then set timeout=10 #第二处 fi fi fi EOF else cat << EOF if [ "x\${timeout}" != "x-1" ]; then if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then set timeout=10 #第三处 fi fi EOF fi fi fi } |
3) 更新grub.cfg
1 | $ sudo update-grub
|
以后,开机就会看到10秒钟的grub菜单。
本作品由 Yysfire 创作,采用进行许可。转载时请在显著位置标明本文永久链接:
http://yysfire.github.io/linux/show-grub-menu-when-ubuntu-12.04-startup.html