[iyunv@www ~]# dd if=/dev/zero of=/dev/sdabs=200 count=1 ##我将磁盘开头的200byte用0全部覆盖,即当前我的bootloader已被破坏1+0 records in1+0 records out200 bytes (200 B) copied, 0.00829572 s,24.1 kB/s此时,在不重启系统的情况下,对grub进行修复[iyunv@www ~]# grub-install--root-directory=/ /dev/sda##这里的—root-directory=/表示可以在磁盘上找到/boot目录的位置Installation finished. No error reported.This is the contents of the device map//boot/grub/device.map.Check if this is correct or not. If any ofthe lines is incorrect,fix it and re-run the script`grub-install'. # this device map was generated by anaconda(hd0) /dev/sda
[iyunv@www ~]# grub ##进入grub交互式界面PRobing devices to guess BIOS drives. Thismay 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,0) root (hd0,0) ##指定boot分区所在位置,和grub.conf中的意义一样Filesystem type is ext2fs, partition type 0x83grub> setup (hd0) ##指明将grub安装到那块磁盘上setup (hd0)Checking if "/boot/grub/stage1"exists... noChecking if "/grub/stage1" exists...yesCheckingif "/grub/stage2" exists... yesChecking if "/grub/e2fs_stage1_5"exists... yesRunning "embed /grub/e2fs_stage1_5(hd0)"... 27 sectors are embedded.succeededRunning "install /grub/stage1 (hd0)(hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeededDone.