ubuntu中的grub2功能和操作方法详解


ubuntu中的grub2功能和操作方法详解
 
各ubuntu版本对应的grub版本号:
 
GRUB 2  Ubuntu since version 9.10 (Karmic Koala)    //grub2 从9.10的ubuntu版本开始使用。
 
Grub version 1.99     Ubuntu 11.04 (Natty Narwhal)
 
改进 Improvements
 
GRUB 2's major improvements over the original GRUB include:
 
Scripting support including conditional statements and functions
Dynamic module loading
Rescue mode
Custom Menus
Themes
Graphical boot menu support and improved splash capability
Boot LiveCD ISO images directly from hard drive
New configuration file structure
Non-x86 platform support (such as PowerPC)
Universal support for UUIDs (not just Ubuntu)
在ubuntu系统中可以使用如下命令查看grub的版本号:
 
         grub-install -v
 
如果只装了一个操作系统,即ubuntu。
 
那么,默认是不会出现grub的启动菜单的。
 
有两种方法可以进入启动菜单:
 
       按键: 点击“SHIFT”  或者 “ESC ”  ,可以进去grub的启动菜单。
 
早期grub版本的配置文件  /boot/grub/menu.lst 在grub2中已经被替换为  /boot/grub/grub.cfg   .
 
grub.cfg         会被某些动作更新。 比如,当一个内核被添加或者移除时,或者当哦难怪乎运行 update -grub 命令时。
 
列出有效linux内核的菜单列表(menu list)是通过运行 update -grub 来自动产生的。
 
grub.cfg 会更新的时候会被覆盖,但是在 /etc/grub.d/  文件夹下有些自定义的配置文件可以使用 如 40_custom  。
 
$ ls /etc/grub.d/
00_header        10_linux      20_memtest86+  40_custom  README
05_debian_theme  20_linux_xen  30_os-prober   41_custom
改变菜单显示设置项的配置文件是: /etc/default/grub
 
[plain]  
# 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=10  
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"  
 
分区编号已经改了!
 
现在第一个分区是 1,而不是 0 。
 
第一个设备驱动(device/drive)依然默认是 hd0 。如果需要,可以再 /boot/grub 下的 device.map 文件中配置。
 
当运行 update-grub 命令的时候,grub会自动去找其他的操作系统。 找到之后,相关的操作系统启动项可以再grub2的 菜单中找到。
 
对配置文件的任何改变不会立即起作用,必须 运行 update-grub 命令 之后才会生效。
 
文件结构  ---- File Structure
GRUB2改变目录的结构层次。 GRUB2的文件夹包括:
 
 /etc/grub.d    ---包括GRUB2的脚本
 
/boot/grub      ---包括GRUB2的模块和 menu文件(grub.cfg)
 
/etc/default/grub   --- 包括用户自定义配置
 
配置GRUB2    ---- Configuring GRUB 2
 
启动失败,进入安全模式
 
 设置安全模式下的 启动菜单超时时间:
 
  /etc/grub.d/00_header  , 找到 约236行 ,即make_timeout()函数的内容。有如下timeout的变量设置:
 
set timeout=0
For timeout=-1, 没有倒计时,会直接显示 启动菜单 。
 
For timeout=0,   即便是进入失败启动,启动菜单也不会显示。
 
For timeout>=1, 启动菜单将停住 一定的时间,这个时间就是这个数字所代表的秒数。
 
改动了之后,一定要 运行 update-grub 命令才生效。
 
上面的改变之后,grub依然会启动至 text graphics 模式。因此,可以修改 /etc/grub.d/10_linux (大约第188行)这个文件的内容来达到 相应的目的。
 
同样需要 运行 update-grub 命令才生效。
 

相关内容

    暂无相关文章