勤&快

问题其实就是你期望的东西和你体验的东西之间的差别
随笔 - 55, 文章 - 0, 评论 - 68, 引用 - 0
数据加载中……

转载:重装Windows后恢复Ubuntu 9.10中的Grub2

原文地址: http://cookiebear.info/archives/353

在已经安装了Ubuntu和Windows双启动的一个硬盘上重新安装Windows,会将Windows的引导代码写入硬盘的MBR,覆盖原本的Grub2。
这时候要恢复Grub2的多重启动,唯有重新安装Grub2了。

首先用Ubuntu Live CD启动机器,然后打开终端输入:

sudo -i

[stextbox id="alert"]注意,以下的操作一定要再三确认,哪怕是一个字符的输入错误都可能导致破坏Ubuntu的系统。[/stextbox]

接着我们要看一下硬盘的文件系统配置方式。

mint ~ # fdisk -l
 
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd25ad25a
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        6527    52428096    7  HPFS/NTFS
/dev/sda2            6528       30401   191767905    f  W95 Ext'd (LBA)
/dev/sda5            6528       18464    95882240    7  HPFS/NTFS
/dev/sda6           18465       29910    91939963+  83  Linux
/dev/sda7           29911       30401     3943926   82  Linux swap / Solaris

由这里看到,我的整个Ubuntu安装在/dev/sda6上,没有划分出boot区和root区。这也是Ubuntu的默认安装模式。
如果你单独划分了boot区,那么请在这一步记住boot的设备名称。

然后执行下面的几步,把之前记住的设备mount出来。
(由于我的系统是基于Ubuntu 9.10的Linux Mint 8,所以命令行提示符有些不一样,但是原理是完全一致的。)

mint ~ # mkdir /media/root
mint ~ # mount /dev/sda6 /media/root
mint ~ # ls /media/root/
bin    dev   initrd.img  media  proc  selinux  tmp  vmlinuz
boot   etc   lib         mnt    root  srv      usr
cdrom  home  lost+found  opt    sbin  sys      var
mint ~ # ls /media/root/boot/
abi-2.6.31-14-generic     initrd.img-2.6.31-14-generic
boot                      memtest86+.bin
config-2.6.31-14-generic  System.map-2.6.31-14-generic
gfxmenu                   vmcoreinfo-2.6.31-14-generic
grub                      vmlinuz-2.6.31-14-generic

mount完毕后确认/medai/root/目录和/media/root/boot/确实和上面的输出一致或者近似。

确认无误后,执行下面的步骤重新安装Grub2。

mint ~ # sudo grub-install --root-directory=/media/root /dev/sda
Installation finished. No error reported.
This is the contents of the device map /media/root/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
 
(hd0)   /dev/sda

完成了上面一步,并且没有错误报告的话,Grub2就安装成功了。
重新启动一下机器,Grub2的多重启动应该已经奏效了。如果你和我一样是对Windows进行了升级,例如从Windows Vista -> Windows 7。
那么在重新进入Ubuntu之后可以在终端下执行:

sudo update-grub

Grub2会自动识别出Windows的版本,并更新启动菜单的显示信息。
在整个操作过程中一定要反复检查输入是否有错误,并且牢记从Ubuntu 9.10开始,由于使用了Grub2。
以往重新安装Grub的老办法不一定适用。

万一,在安装Grub2时遇到了问题,进不了任何一个系统。
请冷静下来,起码你还有Ubuntu Live CD,用它启动系统,进入这个链接寻找适当的解决办法

posted on 2011-02-27 09:48 daning 阅读(2112) 评论(0)  编辑  收藏 所属分类: others


只有注册用户登录后才能发表评论。


网站导航: