3.5 使用 GRUB 配置三启动

对于 GRUB 专家,请继续并根据需要在 CentOS 中的 menu.lst 文件中进行修改。对于 GRUB 新手,以下网址提供了大量信息:https://gnu.ac.cn/software/grub/grub.html,其中大部分内容是不言自明且易于理解的。如果您有任何不理解的地方,请给我发邮件。

GNU GRUB 代表 GRand Unified Bootloader(统一启动加载器),这是一个非常强大的 PC 启动加载程序。GRUB(版本 0.97)的详细手册可以通过以下方式访问:
在 GRUB(版本 0.97)手册的第 4.1 节中,包含了如何成功启动操作系统的秘密。正如其中所述,GRUB 有两种不同的启动方法 - 要么直接启动操作系统,要么当 GRUB 无法为所讨论的操作系统提供原生支持时,它会通过链式加载机制触发操作系统的启动加载程序;从而使操作系统能够成功启动。对于 CentOS 5.2,GRUB 直接加载操作系统,而对于 WinXP,它需要通过链式加载机制来触发 Windows 的启动加载程序。读者应该记住的一点是,链式加载机制通常假设启动加载程序嵌入在安装操作系统的活动分区引导扇区中。

= =  步骤如下 = =


步骤 1:
登录 CentOS 5.2,打开终端,通过使用 su 命令并提供您在安装时提供的密码来获得超级用户权限(称为 root)。

[ghosh@pluton ~]$ su

步骤 2: 一旦您拥有 root 访问权限,请在终端输入以下命令
[root@pluton ghosh]# cd /
[root@pluton /]# cd /boot/grub
[root@pluton grub]# ls -al
[root@pluton grub]# cp grub.conf   grub.conf.bak
这将为 grub.conf 文件创建一个备份文件,该文件是 GNU GRUB 启动加载程序的配置文件。在屏幕上所有文件的列表中,您还可以看到 menu.lst -> ./grub.conf,这意味着 menu.lst 是指向 GRUB 配置文件 grub.conf 的软链接或符号链接。

步骤 3: [root@pluton grub]# vi grub.conf

骤 4: 我的 grub.conf 文件显示在屏幕上:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
#                  all kernel and initrd paths are relative to /, e.g.
#                  root (hd0,2)
#                  kernel /boot/vmlinuz-version ro root=/dev/sda3
#                  initrd /boot/initrd-version.img
# boot=/dev/hda
default=1
timeout=60
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu

title CentOS (2.6.18-92.el5)
           root (hd0,2)
           kernel /boot/bzImage.2.6.18-92.el5  ro  root=LABEL=/    rhgb   quiet    crashkernel=512M@16M
           initrd /boot/initrd-.2.6.18-92.el5.img

title Windows
           rootnoverify (hd0,0)
           chainloader +1


骤 5: 编辑文件内容并添加以蓝色标记的行。

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
#                  all kernel and initrd paths are relative to /, e.g.
#                  root (hd0,2)
#                  kernel /boot/vmlinuz-version ro root=/dev/sda3
#                  initrd /boot/initrd-version.img
# boot=/dev/hda
default=1
timeout=60
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu

title Windows
           rootnoverify (hd0,0)
           chainloader +1

title OpenSolaris
           rootnoverify (hd0,1)
           savedefault
           makeactive
           chainloader +1


title CentOS (2.6.18-92.el5)

           root (hd0,2)
           kernel /boot/bzImage.2.6.18-92.el5  ro  root=LABEL=/    rhgb   quiet    crashkernel=512M@16M
           initrd /boot/initrd-.2.6.18-92.el5.img


骤 6: 我已经根据硬盘中分区的几何布局重新排列了代码。首先是 WinXP,然后是 OpenSolaris 分区,最后是 CentOS 分区。保存并退出 vi 编辑器。

步骤 7: [root@pluton grub]# /sbin/reboot

这将重启 PC。当系统最终启动时,按任意键查看 GNU GRUB 版本 0.97 屏幕,该屏幕显示

Windows
OpenSolaris
CentOS (2.6.18-92.e15)


因此,正如承诺的那样,我们实现了:

a) 成功将新的单个硬盘驱动器分区为主分区和扩展分区,并在其上分别安装了 WinXP FAT32、OpenSolaris ZFS 和 Linux ext3 文件系统。
b) 成功将 Microsoft WinXP 安装在硬盘的第一个主分区上。
c) 成功将 OpenSolaris 2008.11 安装在硬盘的第二个主分区上。
d) 成功将 CentOS 5.2 安装在硬盘的第三个主分区上(Linux 交换分区位于扩展分区的逻辑磁盘驱动器上)
e) 成功编辑了 GRUB 配置文件 /boot/grub/grub.conf,并配置了包含 WinXP、OpenSolaris 和 CentOS 操作系统的三启动系统。



上一页          |          首页          |          下一页