Ubuntu 开机引导文件 /etc/default/grub
1 # If you change this file, run 'update-grub' afterwards to update 2 # /boot/grub/grub.cfg. 3 4 GRUB_DEFAULT=saved 5 GRUB_SAVEDEFAULT=true 6 #GRUB_HIDDEN_TIMEOUT=0 7 GRUB_HIDDEN_TIMEOUT_QUIET=true 8 GRUB_TIMEOUT=10 9 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` 10 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 11 GRUB_CMDLINE_LINUX="" 12 13 # Uncomment to enable BadRAM filtering, modify to suit your needs 14 # This works with Linux (no patch required) and with any kernel that obtains 15 # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) 16 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" 17 18 # Uncomment to disable graphical terminal (grub-pc only) 19 #GRUB_TERMINAL=console 20 21 # The resolution used on graphical terminal 22 # note that you can use only modes which your graphic card supports via VBE 23 # you can see them in real GRUB with the command `vbeinfo' 24 #GRUB_GFXMODE=640x480 25 26 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux 27 #GRUB_DISABLE_LINUX_UUID=true 28 29 # Uncomment to disable generation of recovery mode menu entries 30 #GRUB_DISABLE_LINUX_RECOVERY="true" 31 32 # Uncomment to get a beep at grub start 33 #GRUB_INIT_TUNE="480 440 1"
对于grub2,ubuntu给了一个官方的配置文件/etc/default/grub。大部分情况下grub2的设置都可以在这个文件中搞定,而且这个文件结构也比较简单,修改起来也容易。完全没有必要直接改/boot/grub/grub.cfg或者/etc/grub.d/下的文件。
修改/etc/default/grub只需简单一个命令:sudo gedit /etc/default/grub
下面是系统默认的内容,以及最常用的修改菜单显示时间和默认操作系统的方法:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=0 #将0改为saved,可让grub记住上次启动时选择的系统
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="5" #显示启动选择菜单的时间
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# 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 entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"
修改完成后使用命令:
代码:sudo update-grub
会自动更新/boot/grub/grub.cfg,这样做最大的好处是当系统更新内核时,你的设置不会被覆盖掉。
另外对于从9.10 beta及以前一路升级上来的朋友,如果确定想使用grub2,手动运行:
代码:sudo apt-get install grub2
升级并确保grub2正确配置。(我全新安装的9.10 beta,一路升级上来后,系统中的grub工具居然还是老版,运行这个命令后才正常)
其实Ubuntu官方wiki上对这些都有说明:
https://wiki.ubuntu.com/Grub2
PS: 官方文件只说/boot/grub/grub.cfg不要手工修改,这个文件是运行update-grub自动生成的,/etc/default/grub和/etc/grub.d/ (folder)都很重要。
要修改配置文件的只要打开/boot/grub/grub.cfg文件,找到想修改的地方,然后根据注释找到相应的/etc/default/grub或/etc/grub.d/ (folder)进行修改,很方便滴。
File Structure
/boot/grub/grub.cfg This is in keeping with the intent that the file should not be edited manually.
/etc/default/grub
/etc/grub.d/ (folder)