Grub 的配置文件位于 "/boot/grub/grub.conf", 更改后将对以后的每次启动有效。 此配置文件可分为两个大的部分:全局配置和菜单项配置:

grub.conf
  1. # grub.conf generated by anaconda  
  2. #  
  3. # Note that you do not have to rerun grub after making changes to this file  
  4. # NOTICE:  You have a /boot partition.  This means that  
  5. #          all kernel and initrd paths are relative to /boot/, eg.  
  6. #          root (hd0,1)  
  7. #          kernel /vmlinuz-version ro root=/dev/VolGroup_ID_11074/LogVol1  
  8. #          initrd /initrd-version.img  
  9. #boot=/dev/sda2  
  10. default=0 
  11. timeout=5 
  12. splashimage=(hd0,1)/grub/splash.xpm.gz  
  13. hiddenmenu  
  14. title Red Hat Enterprise Linux AS (2.6.24)  
  15.         root (hd0,1)  
  16.         kernel /vmlinuz-2.6.24 ro root=/dev/VolGroup_ID_11074/LogVol1 rhgb quiet  
  17.         initrd /initrd-2.6.24.img  
  18. title Red Hat Enterprise Linux AS (2.6.23.17)  
  19.         root (hd0,1)  
  20.         kernel /vmlinuz-2.6.23.17 ro root=/dev/VolGroup_ID_11074/LogVol1 rhgb quiet  
  21.         initrd /initrd-2.6.23.17.img  
  22. title Red Hat Enterprise Linux AS (2.6.9-78.EL)  
  23.         root (hd0,1)  
  24.         kernel /vmlinuz-2.6.9-78.EL ro root=/dev/VolGroup_ID_11074/LogVol1 rhgb quiet  
  25.         initrd /initrd-2.6.9-78.EL.img  
  26. title Red Hat Enterprise Linux AS (2.6.9-78.ELsmp)  
  27.         root (hd0,1)  
  28.         kernel /vmlinuz-2.6.9-78.ELsmp ro root=/dev/VolGroup_ID_11074/LogVol1 rhgb quiet  
  29.         initrd /initrd-2.6.9-78.ELsmp.img  
  30. title Red Hat Enterprise Linux AS-up (2.6.9-78.EL)  
  31.         root (hd0,1)  
  32.         kernel /vmlinuz-2.6.9-78.EL ro root=/dev/VolGroup_ID_11074/LogVol1 rhgb quiet  
  33.         initrd /initrd-2.6.9-78.EL.img 

      A. 全局配置命令

            全局配置命令从配置文件最上方到第一个 "title" 命令之前结束。

            default 0
            timeout 10
            splashimage (hd0,2)/boot/grub/splash.xpm.gz
            password --md5 $1$tBWhgwVY$sIzNYKY/iV9rZ4keYAkaQ/ #设置了密码的才有此项

            a. default 菜单号: 指定 Grub 默认启动项(默认引导的系统), 菜单号从0 开始, 0 表示下面的第一个菜单项。当与 "savedefault" 命令同时使用时可以有 "default saved" 的特殊格式, 表示默认由 "savedefault" 所保存过的菜单项。

            b. timeout seconds: 从 Grub 启动界面出现到以默认启动项引导系统之间等待用户选择的时间。

            c. splashimage full_path_of_xpm_or_xpm.gz: 指定启动菜单的背景文件(xpm 图像或其gzip 压缩文件)。

      B. 菜单项配置

            从”title”开始到下一个 "title" 之前为一个启动菜单项, 即引导一个操作系统所需的参数。Grub 对不同的操作系统有不同的引导方式, 对 Linux 系统 Grub 可直接加载其内核并启动; 对Windows/Solaris 系统 Grub 不能直接加载其系统核心文件进行引导, 而是通过调用 Windows 自身的启动引导器, 通常为 Windows 所在分区的引导扇区(不是整个硬盘的首扇区 MBR)。

            a. 配置Linux 的启动菜单项 (以 RedHat Linux 9 和 OpenDesktop 1.0 (www.opendesktop.net)为例):
                  i. RedHat Linux 9:

                  title Red Hat Linux (2.1.20-8)
                  root (hd0,0)
                  kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
                  initrd /boot/initrd-2.4.20-8.img

                  title: 定义启动菜单项的名称
                  root: 设置 Grub 的根设备 (root)为 Linux 内核所在分区
                  kernel: 后跟 Linux 内核文件为参数, 加载 Linux 内核文件
                  initrd: 加载镜像文件

                  ii. OpenDesktop 1.0:

                  title OpenDesktop 1.0 (2.4.22-1.3)
                  root (hd0, 4)
                  knernel /boot/vmlinuz-2.4.22-1.3.OpenDesktop.1.nptl ro root=/dev/hda4 vga=791 splash=silent
                  initrd /boot/initrd-2.4.22-1.3.OpenDesktop.1.nptl.img

            b. 配置非Linux 的启动菜单项(以Windows 2000 为例, 其它非Linux 系统也类似, 如Solaris 10 x86):

            title Microsoft Windows 2000 Professional
            rootnoverify (hd0,0)
            chainloader +1

            rootnoverify: 设置 Grub 的根设备(root)为 Windows 系统所在分区, 但不加载文件系统。
            Chainloader: 调用 Windows 分区的引导器引导 Windows 系统
此文章由 flyinweb 于 2009-07-27 12:46:34 编辑

本日志由 flyinweb 于 2009-07-27 10:16:13 发表,目前已经被浏览 4122 次,评论 0 次;

作者添加了以下标签: GrubLinux

引用通告:http://www.517sou.net/Article/157/Trackback.ashx

评论订阅:http://www.517sou.net/Article/157/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)