Ubuntu 引导区修复

国庆假期,笔记本的安装的window & ubuntu双系统的引导区被window的修复工具覆盖了,导致ubuntu 10.04不能正常启动,使用下列的方法修复了,修复后双系统启动正常。

Recover Grub 2 via LiveCD

  • First, grab a copy of the latest Ubuntu LiveCD and boot it.

  • Open a terminal and type

$ sudo fdisk -l

  • Now, you need to remember which device listed is your linux distribution, for reference, /dev/sda1 will be used. Now we need to mount the filesystem to /mnt

$ sudo mount /dev/sda1 /mnt

  • If you have /boot on a separate partition, that need's to be mounted aswell. For reference, /dev/sda2 will be used.

$ sudo mount /dev/sda2 /mnt/boot

  • If you have /var on a separate partition, that need's to be mounted aswell. For reference, /dev/sda3 will be used.

$ sudo mount /dev/sda3 /mnt/var Make sure you don't mix these up, pay attention to the output of FDISK

  • Now mount the rest of your devices and some other things needed in the chroot

$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys

  • Now chroot into your system

$ sudo chroot /mnt

You should be chroot'd into your system as root, you can now run commands as root, without the need for sudo.

  • Now you need to edit the /etc/default/grub file to fit your system

$ nano /etc/default/grub

  • When that is done you need to run update-grub to create the configuration file. If you have a separate /boot partition you need to mount it first!

$ update-grub

  • To install GRUB 2 to the MBR, next you need to run grub-install /dev/sda

$ grub-install /dev/sda

  • If you encounter any errors, try grub-install --recheck /dev/sda

$ grub-install --recheck /dev/sda

  • Press Ctrl+D to exit out of the chroot.
  • Once you exit back to your regular console, undo all the mounting, first the /dev and others

$ sudo umount /mnt/dev
$ sudo umount /mnt/sys
$ sudo umount /mnt/proc

  • Now you can unmount the root system. (But if you have a separate boot partition which you mounted earlier, you have to unmount this first, or you will get a "device busy" error message.)

$ sudo umount /mnt

  • And you should be free to restart your system right into GRUB 2 and then into your system installation.

If you had alternate OS entries, update-grub might say "Cannot find list of partitions!". Ignore it and continue - once you can boot into your linux installation, do so and then rerun update-gruband grub-install /dev/sda as root.

 

Restore GRUB2 - Recovering from a Windows XP / Vista / 7 Reinstallation

Fire up a terminal from the Live CD for Ubuntu 10.04.
$ sudo fdisk -l (Note the partition number on which Linux resides)
$ sudo mount /dev/sdaX /mnt (Replace X with the partition number housing Linux)
$ sudo grub-install --root-directory=/mnt/ /dev/sda
$ sudo update-grub
$ sudo reboot

Credits to
http://mundogeek.net/archivos/2009/12/08/recuperar-grub-2/ for the enlightening post & 
http://www.webupd8.org/2009/12/how-to-recover-grub2-linux.html for the awesome translation.

 

Errors

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值