红联Linux门户
Linux帮助

双硬盘双win8加ubuntu修复grub

发布时间:2015-10-09 09:51:29来源:kangear作者:linux人

双硬盘双win8加ubuntu是条件,grub已经不能够启动了,要修复一下,使其能够启动这个3个系统。具体的分布是:硬盘A+Win8A 硬盘B+Win8B+ubuntu。现在默认启动的是Win8A。

使用LinuxLive USB Creator制作usb live,然后从u盘启动。


按照如下操作:
How to Repair, Restore, or Reinstall Grub 2 with a Ubuntu Live CD or USB

Grub 2 typically gets overridden when you install Windows or another Operating System. To make Ubuntu control the boot process, you need Reinstall (Repair/Restore) Grub using a Ubuntu Live CD.

Warning

Using the sudo command, especially from a Live CD can do serious damage to your system. Read all instructions and confirm you understand before executing any commands. When pasting into the Terminal, use Ctrl+Shift+V, NOT Ctrl+V.

Terminal Commands

Mount the partition your Ubuntu Installation is on. If you are not sure which it is, launch GParted (included in the Live CD) and find out. It is usually a EXT4 Partition. Replace the XY with the drive letter, and partition number, for example: sudo mount /dev/sda1 /mnt.
sudo mount /dev/sdXY /mnt

Now bind the directories that grub needs access to to detect other operating systems, like so.
sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys

Now we jump into that using chroot.

Now install, check, and update grub.

This time you only need to add the drive letter (usually a) to replace X, for example: grub-install /dev/sda, grub-install –recheck /dev/sda.
grub-install /dev/sdX
grub-install --recheck /dev/sdX

Now grub is back, all that is left is to exit the chrooted system and unmount everything.
exit &&
sudo umount /mnt/sys &&
sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts &&
sudo umount /mnt/dev &&
sudo umount /mnt

Shut down and turn your computer back on, and you will be met with the default Grub2 screen.

You may want to update grub or re-install burg however you like it.
Congratulations, you have just Repaired/Restored/Reinstalled Grub 2 with a Ubuntu Live CD!


这里说下注意事项:
1.制作的usb live用的ubuntu版本要和硬盘上已经装的位数(同为32或者64)一致且最好是同一版本.否则有些命令不能使用。
2.对于第4步的grub-install /dev/sdX,后边的“X”要是现在默认启动的硬盘,如这边的情况,应该对应的是硬盘A。
3.如何查看硬盘上不能启动的ubuntu的版本号,可以去/etc/os-release中查看,也可以grep "VERSION" /etc -rn
4.如遇到“chroot:failed to run command '/bin/bash' :Exec Format error”,说明犯了1错误
5.关于让默认启动Win8的问题,修改/etc/grub.d/30_os-prober不再好使,因为它会prober出两个win8最终还是不知道要启动哪一个。如果要修改可以修改/boot/grub/grub.cfg。


Ubuntu修复Grub2笔记:http://www.linuxdiyf.com/linux/11796.html

Windows与Ubuntu双系统重装WIN7后修复Grub2:http://www.linuxdiyf.com/linux/4481.html

重装win7 修复Grub操作步骤分析:http://www.linuxdiyf.com/linux/719.html

Ubuntu系统grub修复的方法:http://www.linuxdiyf.com/linux/12961.html

重装Windows系统后Ubuntu Grub2的恢复:http://www.linuxdiyf.com/linux/11820.html