SDB:Repair MBR after Windows install

跳转到:导航搜索


在 openSUSE 上测试

推荐文章


情况

在Linux旁边安装Windows后,GRUB已被Windows引导加载程序取代。您如何将GRUB恢复到MBR?

请注意“已被”。如果openSUSE按照建议安装,以保留一个中立MBR,那么Grub将被安装到分区而不是MBR,这将导致一个更简单的“修复”过程。

流程

您必须确保能够启动到openSUSE。您可以通过使用安装DVD上的Rescue System模式,或者使用带有Plop Boot ManagerSuper Grub Disk的CD来做到这一点。请注意,您可以使用UNetbootin让USB启动任何ISO镜像。然后您可以使用几个命令修复主引导记录

如果使用grub2(openSUSE 13.1的默认设置)

打开终端并输入命令。首先提升您的权限(在Rescue System模式下不需要)

sudo -i

从分区表中找出您的(主)Linux分区,例如/dev/sda3

fdisk -l

然后输入

mount /dev/sda3 /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc # maybe superfluous
mount --bind /sys /mnt/sys # maybe superfluous
mkdir /mnt/mounts # could be needed if booted with rescue openSUSE 13.1
mount --rbind /mounts /mnt/mounts # could be needed if booted with rescue openSUSE 13.1

如果准备工作顺利,执行实际的更改

chroot /mnt
grub2-install /dev/sda
exit

如果成功了,

reboot

如果使用传统grub

打开终端并输入(在Rescue System模式下不需要'sudo')

 sudo /usr/sbin/grub

然后执行以下命令

 grub> find /boot/grub/stage2 (will show the path of actual grub installation, you will need on the next step)
 grub> root (hdx,y)
 grub> setup (hdx)
 grub> quit

警告:x代表磁盘编号,y代表安装GRUB stage2的分区编号。编号从0开始。例如,如果第一个命令输出(hd0,5),您应该执行root (hd0,5),然后是setup (hd0)。重新启动后,GRUB菜单应该重新出现。

此解决方案来自论坛上的please_try_again

如果使用了中立MBR

所有必需的操作是使用任何可用的分区工具将引导标志从Windows分区移动到安装了Grub的分区。这可以使用FDISK(将引导标志称为活动标志)从DOS启动,或者从Windows启动的DISKPART或磁盘管理,或者使用来自通用可引导介质(如Ultimate Boot CDHiren's BootCD)的分区工具轻松完成。

参见