- ubuntu16.04.07加windows10后无法启动ubunu的问题
- 解决boot-repair的安装方法同样适用于ubuntu18.04 ubuntu20.01等系统不能启动的问题。
- 对boot-repair修复的原理进行分析
问题描述
问题1
在首先安装windows10后,再次安装ubuntu能够正常启动两个系统。但在安装ubuntu16.04后再重新安装windows10(未动ubuntu分区)后无法启动ubuntu。
原因是windows安装过程中比较霸道,自行将ubuntu的引导破坏,需要重新安装/修复ubuntu的引导
问题2
在安装boot-repair时出现找不到包,无法定位到boot-repair包的问题
ubuntu@ubuntu:/etc/apt/sources.list.d$ sudo apt-get install boot-repair
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package boot-repair
解决方法
参考文https://blog.csdn.net/Q_upup/article/details/103705100?spm=1001.2014.3001.5502进行ubuntu修复。进入ubuntu启动盘后,联网按照如下安装
sudo add-apt-repository ppa:yannubuntu/boot-repair #回车确认添加
sudo apt-get update
sudo apt-get install boot-repair
boot-repair
点击recommanded repair等待修复即可。
如果出现E: Unable to locate package boot-repair
的问题,修改一下ppa的源即可
进入目录修改文件
cd /etc/apt/sources.list.d/
sudo gedit yannubuntu-ubuntu-boot-repair-xenial.list
修改文件内容为如下(把xenial改成bionic,即更换一个ubuntu的发行版本号从16.04的xenial到18.04的bionic,推测可能是作者更新时遗漏或者什么问题, 可在网站http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu中看见各发行版本下内容其实是存在的)
deb http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu bionic main
# deb-src http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu bionic main
再次更新安装即可
sudo apt-get update
sudo apt-get install boot-repair
boot-repair
运行后点击recommand repair即可
boot-repair修复原理
对boot-repair的修复日志进行查看,可以知道其修复过程大致为以下几步
- 删除windows休眠文件(针对设置未快捷启动的windows)>
- Reinstall the grub-efi-amd64,
- 删除旧引导
以下为修复日志
boot-repair-4ppa130 [20211110_0629]
============================= Boot Repair Summary ==============================
mount -t ntfs-3g -o remove_hiberfile /dev/nvme0n1p3 /mnt/boot-sav/nvme0n1p3
Error code 14
mount -r /dev/nvme0n1p3 /mnt/boot-sav/nvme0n1p3
mount -t ntfs-3g -o remove_hiberfile /dev/nvme0n1p4 /mnt/boot-sav/nvme0n1p4
Error code 14
mount -r /dev/nvme0n1p4 /mnt/boot-sav/nvme0n1p4
mount -t ntfs-3g -o remove_hiberfile /dev/nvme0n1p5 /mnt/boot-sav/nvme0n1p5
Error code 14
mount -r /dev/nvme0n1p5 /mnt/boot-sav/nvme0n1p5
mount -t ntfs-3g -o remove_hiberfile /dev/nvme0n1p3 /mnt/boot-sav/nvme0n1p3
Error code 14
mount -r /dev/nvme0n1p3 /mnt/boot-sav/nvme0n1p3
Windows is hibernated, refused to mount.
Failed to mount ‘/dev/nvme0n1p3’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p3’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p4’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p4’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p5’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p5’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
=================== /boot detected. Please check the options.
Recommended repair: ____________________________________________________________
The default repair of the Boot-Repair utility will reinstall the grub-efi-amd64-signed of
nvme0n1p8,
using the following options: nvme0n1p7/boot, nvme0n1p1/boot/efi,
Additional repair will be performed: unhide-bootmenu-10s win-legacy-basic-fix use-standard-efi-file
/boot added in nvme0n1p8/fstab
/boot/efi added in nvme0n1p8/fstab
Quantity of real Windows: 1
Mount nvme0n1p7 on /mnt/boot-sav/nvme0n1p8/boot
Mount nvme0n1p1 on /mnt/boot-sav/nvme0n1p8/boot/efi
No nvme0n1p8/boot/efi/efi/ ubuntu/mint folder
=============== Reinstall the grub-efi-amd64-signed of nvme0n1p8 ===============
grub-install --version
grub-install (GRUB) 2.02~beta2-36ubuntu3.27
efibootmgr -v from chroot before grub install
BootCurrent: 0014
Timeout: 0 seconds
BootOrder: 0001,0000,0016,0012,0013,0015,0014,0017
Boot0000* Windows Boot Manager HD(1,GPT,67360052-65b2-4fbd-8481-9eb139e75380,0x800,0x32000)/File(EFIMicrosoftBootbootmgfw.efi)WINDOWS…x…B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}…d……
Boot0001* ubuntu HD(2,GPT,38d944a8-455c-4bca-be79-ea1b996cbc43,0xe1800,0x32000)/File(EFIubuntugrubx64.efi)
Boot0010 Setup FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011 Boot Menu FvFile(86488440-41bb-42c7-93ac-450fbf7766bf)
Boot0012* NVMe: HFM512GDHTNG-8310A PciRoot(0x0)/Pci(0x1d,0x0)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)…2.LN…
Boot0013* ATA HDD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f602)
Boot0014* USB HDD: TOSHIBA TransMemory PciRoot(0x0)/Pci(0x14,0x0)/USB(12,0)3.!..3.G…A…
Boot0015* USB FDD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0016* USB CD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0017* USB LAN: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,e854bca4cae7704ca322b00da0376322)
uname -r
4.15.0-112-generic
grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
Installing for x86_64-efi platform.
Installation finished. No error reported.
df /dev/nvme0n1p1
mv /mnt/boot-sav/nvme0n1p8/boot/efi/EFI/Boot/bootx64.efi /mnt/boot-sav/nvme0n1p8/boot/efi/EFI/Boot/bkpbootx64.efi
cp /mnt/boot-sav/nvme0n1p8/boot/efi/EFI/ubuntu/grubx64.efi /mnt/boot-sav/nvme0n1p8/boot/efi/EFI/Boot/bootx64.efi
grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
Installing for x86_64-efi platform.
Installation finished. No error reported.
efibootmgr -v from chroot after grub install
BootCurrent: 0014
Timeout: 0 seconds
BootOrder: 0001,0000,0016,0012,0013,0015,0014,0017
Boot0000* Windows Boot Manager HD(1,GPT,67360052-65b2-4fbd-8481-9eb139e75380,0x800,0x32000)/File(EFIMicrosoftBootbootmgfw.efi)WINDOWS…x…B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}…d……
Boot0001* ubuntu HD(1,GPT,67360052-65b2-4fbd-8481-9eb139e75380,0x800,0x32000)/File(EFIubuntugrubx64.efi)
Boot0010 Setup FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011 Boot Menu FvFile(86488440-41bb-42c7-93ac-450fbf7766bf)
Boot0012* NVMe: HFM512GDHTNG-8310A PciRoot(0x0)/Pci(0x1d,0x0)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)…2.LN…
Boot0013* ATA HDD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f602)
Boot0014* USB HDD: TOSHIBA TransMemory PciRoot(0x0)/Pci(0x14,0x0)/USB(12,0)3.!..3.G…A…
Boot0015* USB FDD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0016* USB CD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0017* USB LAN: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,e854bca4cae7704ca322b00da0376322)
chroot /mnt/boot-sav/nvme0n1p8 update-grub
Generating grub configuration file …
Found linux image: /boot/vmlinuz-4.15.0-112-generic
Found initrd image: /boot/initrd.img-4.15.0-112-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
Windows is hibernated, refused to mount.
Failed to mount ‘/dev/nvme0n1p3’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/nvme0n1p3’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.
Boot successfully repaired.
You can now reboot your computer.
Please do not forget to make your UEFI firmware boot on the Ubuntu 16.04.7 LTS entry (nvme0n1p1/EFI/ubuntu/grubx64.efi file) !
If your computer reboots directly into Windows, try to change the boot order in your UEFI firmware.
If your UEFI firmware does not allow to change the boot order, change the default boot entry of the Windows bootloader.
For example you can boot into Windows, then type the following command in an admin command prompt:
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi