问题描述:

    由于在windows上进行更新/重装/修改了引导设置以后,windows会“自私”地重写引导,导致Ubuntu系统引导消失而无法选择Ubuntu启动。

bios boot选项ubuntu ubuntu boot-repair_Windows

 

 

Boot Repair的功能和特点:

1、简单易用。

2、界面左下角的“advanced options”中还有许多针对grub引导菜单的高级设置。

3、这个软件适用xp、vista、windows 7

4、适用于debian、ubuntu系列(包括Xubuntu、Kubuntu)及其衍生版本Linux mint等。

5、支持轻松修复GRUB/GRUB2引导器。

6、如果是高手的话,也可以利用Boot Repair来修复fedora、opensuse、archlinux等其他linux系统,当然,方法就不一样了。

 

 

 

 

问题解决方法:

1.类似windows进入PE模式,我们选择以 liveCD 的方式 进入Ubuntu系统。

(准备一个U盘,备份好数据后格式化 ,在Universal USB Installer 对U盘进行写入)

bios boot选项ubuntu ubuntu boot-repair_Ubuntu_02

 

2.BIOS中打开UEFI,GPT启动模式。设置U盘启动,且U盘必须为UEFI模式启动。

(这一步比较重要,如果U盘以legacy模式启动,会导致最终boot-repair无法修复)

 

3.重启,成功以后,开机->选择试用Try ubuntu without install。

bios boot选项ubuntu ubuntu boot-repair_ubuntu_03

 

4.打开终端,添加boot-repair源到软件源中并安装。

(由于liveCD中的源是外国的,建议在此之前更新到国内的源以加快速度)

sudo add-apt-repository ppa:yannubuntu/boot-repair -y

sudo apt-get update

sudo apt-get install boot-repair -y

 

5.运行boot-repair,通常选择Recommend repair即可,根据提示走即可。

(如果遇到The current session is in Legacy mode. Please reboot the computer, and use this software in an EFI session. This will activate the function. For example, use a live-USB of Boot-Repair-Disk-64bit, after making sure your BIOS is set up to boot USB in EFI mode. 证明liveCD的启动方式错误,应该重新选择以UEFI模式启动)

bios boot选项ubuntu ubuntu boot-repair_bios boot选项ubuntu_04

 

修复完成以后重启会发现一大堆无关的启动选项。

bios boot选项ubuntu ubuntu boot-repair_ubuntu_05

 

6.删除多余的启动项

进入我们重新恢复的Ubuntu以后,打开终端,输入以下命令。

sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg_backup  #先备份一下
cat /boot/grub/grub.cfg > tmp  #将内容重定向到其他文件,便于修改
sudo gedit tmp  #或者vim tmp
 
#将下面这些内容全部删掉(从 begin ..custom 到 end ..custom)
### BEGIN /etc/grub.d/25_custom ###

 menuentry "Windows UEFI bootmgfw.efi" {
 search --fs-uuid --no-floppy --set=root 84F5-6727
 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
 }

 menuentry "Windows Boot UEFI loader" {
 search --fs-uuid --no-floppy --set=root 84F5-6727
 chainloader (${root})/EFI/Boot/bkpbootx64.efi
 }

 ...

menuentry "Windows Boot UEFI recovery bkpbootx64.efi" {
search --fs-uuid --no-floppy --set=root 5686-D913
chainloader (${root})/efi/Boot/bkpbootx64.efi
}
### END /etc/grub.d/25_custom ###

 

删掉之后再:

 

sudo cat tmp > /boot/grub/grub.cfg

 

以上。