当前位置:Linux教程 - Linux综合 - GRUB的交互性

GRUB的交互性

GRUB 最好的优点之一就是其强健的设计 -- 在不断使用它时请别忘了这点。如果更新内核或更改它在磁盘上的位置,不必重新安装 GRUB。事实上,如有必要,只要更新 menu.lst 文件即可,一切将保持正常。 只有少数情况下,才需要将 GRUB 引导装入器重新安装到引导记录。首先,如果更改 GRUB root 分区的分区类型(例如,从 ext2 改成 ReiserFS),则需要重新安装。或者,如果更新 /boot/grub 中的 stage1 和 stage2 文件,由于它们来自更新版本的 GRUB,很有可能要重新安装引导装入器。其它情况下,可以不必理睬! GRUB的最大的特点就是交互性特别强。在开机时,按一下“c”,将进入GRUB 控制台。显示如下: GRUB version 0.5.96.1 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first Word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> 欢迎使用 GRUB 控制台。现在,再研究命令: 我将通过GRUB 控制台绕过lilo来启动RedHat Linux, grub> root (h 现在,按一次 Tab 键。如果系统中有多个硬盘,GRUB 将显示可能完成的列表,从 "hd0" 开始。如果只有一个硬盘,GRUB 将插入 "hd0,"。如果有多个硬盘,继续进行,在 ("hd2") 中输入名称并在名称后紧跟着输入逗号,但不要按 Enter 键。部分完成的 root 命令看起来如下: grub> root (hd0, 现在,继续操作,再按一次 Tab 键。GRUB 将显示特定硬盘上所有分区的列表,以及它们的文件系统类型。在我的系统中,按 Tab 键时得到以下列表: grub> root (hd0, (tab,按tab一下键) Possible partitions are: Partition num: 0, Filesystem type is fat, partition type 0x6 Partition num: 2, Filesystem type is ext2fs, partition type 0x83 Partition num: 4, Filesystem type unknown, partition type 0x7 Partition num: 5, Filesystem type is ext2fs, partition type 0x83 Partition num: 6, Filesystem type is fat, partition type 0xb Partition num: 7, Filesystem type is fat, partition type 0xb Partition num: 8, Filesystem type is ext2fs, partition type 0x83 Partition num: 9, Filesystem type unknown, partition type 0x82 如您所见,GRUB 的交互式硬盘和分区名称实现功能非常有条理。这些,只需要好好理解 GRUB 新奇的硬盘和分区命名语法,然后就可以继续操作了 grub> root (hd0,8) 现在已安装了 root 文件系统,到装入内核的时候了 grub> kernel /boot/vmlinuz-2.4.2 root=/dev/hda5 ro [Linux-bzImage, setup=0x1200, size=0xe1a30] 您已经安装了 root 文件系统并装入了内核。现在,可以引导了。只要输入 "boot",Linux 引导过程就将开始。是不是很cool啊,GRUB的menu.lst更像一个linux下的脚本程序。

(出处:http://www.sheup.com)