第一步:使用Live CD启动进入系统
准备一张Fedora 8或Fedora 9的Live CD启动盘,也可以使用其他带有图形化安装界面的Linux发行版。将光盘放入光驱并启动系统后,按照安装向导一直到进入桌面环境——即桌面上显示有文件夹图标、计算机图标以及“Install”图标的界面。此时,点击左上角的Fedora菜单,找到“系统工具”选项,并选择“终端”以打开命令行窗口。
第二步:在终端中执行GRUB重装命令
具体操作步骤请参见下面的代码示例(注意:代码中加粗的部分需要根据您的实际硬盘分区情况进行调整):
| 命令示例: |
| [fedora@localhost ~]$ grub bash: grub: command not found [fedora@localhost ~]$ whereis grub grub: /sbin/grub /usr/share/grub /usr/share/man/man8/grub.8.gz [fedora@localhost ~]$ su [root@localhost fedora]# /sbin/grub Probing devices to guess BIOS drives. This may take a long time. GNU GRUB version 0.97 (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> root (hd0,7) root (hd0,7) Filesystem type is ext2fs, partition type 0×83 grub> setup (hd0) setup (hd0) Checking if “/boot/grub/stage1″ exists… yes Checking if “/boot/grub/stage2″ exists… yes Checking if “/boot/grub/e2fs_stage1_5″ exists… yes Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 23 sectors are embedded. succeeded Running “install /boot/grub/stage1 (hd0) (hd0)1+23 p (hd0,7)/boot/grub/stage2 /boot/grub/grub.conf”… succeeded Done. grub> |
第三步:详细解析每一步的命令含义
首先,我们来解析上述命令的操作过程:使用su命令切换到root用户(系统会提示输入root密码),然后输入/sbin/grub启动GRUB交互界面,此时您将看到grub>提示符。接着,执行root (hd0,7)命令——注意root后面必须有一个空格,否则命令无效。这里的hd0代表第一块硬盘(数字0表示硬盘编号,若您的系统安装在第二块硬盘,请将0改为1),而7代表分区编号。如果您不确定具体分区号,可以返回桌面双击“Install”图标,进入安装向导的分区选择页面,即可看到Fedora所在的分区编号(例如本例中为第7分区)。确认分区后,再输入setup (hd0)命令,同样注意setup后面有空格,且硬盘编号必须与前面root中的一致。执行成功后,终端会显示“succeeded”信息,表明GRUB已成功重新写入MBR。
最后,彻底关掉系统,取出Live CD光盘并重新启动计算机。检查GRUB引导菜单是否正常恢复?如果仍未成功,通常是因为分区编号或硬盘编号输入有误。请再次核对您的磁盘分区布局,重新执行上述步骤。
