重新恢复GRUB

今天用优化大师清理系统分区的杂碎,结果重新起动后不能进启动菜单,我的启动菜单是GRUB。一开始我用WIN7安装盘的恢复功能来尝试恢复,它一开始就报启动信息有问题,但是修复完成重起后发现还是不行。然后是差点重装系统,但是仔细一想,连GRUB都进不了,是不是GRUB坏了?于是拿出Ubuntu 10.04的安装盘进入Live系统,快速ADSL上网后,就找到了下面这篇文章,重新安装了GRUB。顺利进入WIN7系统。

 

This method of installation uses the chroot command to gain access to the broken system’s files. Once the chroot command is issued, the LiveCD treats the broken system’s / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.

  1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later).
  2. Open a terminal – Applications, Accessories, Terminal.
  3. Determine your normal system partition – (the switch is a lowercase “L”)sudo fdisk -l
    • If you aren’t sure, rundf -Th. Look for the correct disk size and ext3 or ext4 format.
  4. Mount your normal system partition:
    • Substitute the correct partition: sda1, sdb5, etc.

    sudo mount /dev/sdXX /mnt # Example: sudo mount /dev/sda1 /mnt

  5. Only if you have a separate boot partition:
    • sdYY is the /boot partition designation (examply sdb3)
    • sudo mount /dev/sdYY /mnt/boot
  6. Mount devices:sudo mount --bind /dev/ /mnt/dev
  7. To ensure that only the grub utilities from the LiveCD get executed, mount /usrsudo mount --bind /usr/ /mnt/usr
  8. mount proc filesystemsudo mount --bind /proc/ /mnt/proc
  9. Chroot into your normal system device:sudo chroot /mnt
  10. If there is no /boot/grub/grub.cfg or it’s not correct, create one usingupdate-grub
  11. Reinstall GRUB 2:
    • Substitute the correct device – sda, sdb, etc. Do not specify a partition number.

    grub-install /dev/sdX

  12. Verify the install (use the correct device, for example sda. Do not specify a partition): sudo grub-install --recheck /dev/sdX
  13. Exit chrootCTRL-D on keyboard
  14. Unmount devices:sudo umount /mnt/dev
    • If you mounted a separate /boot partition:sudo umount /mnt/boot
  15. Unmount last device:sudo umount /mnt
  16. Reboot.reboot

Post-Restoration Commands

Once the user can boot to a working system, try to determine why the system failed to boot. The following commands may prove useful in locating and/or fixing the problem.

To refresh the available devices and settings in /boot/grub/grub.cfg

  • sudo update-grub

To look for the bootloader location.

  • grub-probe -t device /boot/grub

To install GRUB 2 to the sdX partition’s MBR (sda, sdb, etc.)

  • sudo grub-install /dev/sdX

To recheck the installation. (sda, sdb, etc.) sudo grub-install --recheck /dev/sdX

Please check the following link for further details.

 

 

 

https://help.ubuntu.com/community/Grub2#Reinstalling%20GRUB%202

posted on 2010-06-15 18:28  星际浪子  阅读(1515)  评论(0编辑  收藏  举报

导航