ubuntu 16.04无法locate boot-repair的解决方法

  1. ubuntu16.04.07加windows10后无法启动ubunu的问题
  2. 解决boot-repair的安装方法同样适用于ubuntu18.04 ubuntu20.01等系统不能启动的问题。
  3. 对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的修复日志进行查看,可以知道其修复过程大致为以下几步

  1. 删除windows休眠文件(针对设置未快捷启动的windows)>
  2. Reinstall the grub-efi-amd64,
  3. 删除旧引导

以下为修复日志

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

### Ubuntu 16.04 上 `sudo apt-get install python2.5` 报错的原因分析 在 Ubuntu 16.04 中,默认支持 Python 的版本为 Python 2.7 和 Python 3.x。Python 2.5 并未被官方仓库所支持,因此尝试通过 `apt-get` 安装 Python 2.5 可能会遇到以下问题: #### 原因一:软件源中不存在 Python 2.5 Ubuntu 的 APT 包管理器依赖于其官方或第三方软件源来获取软件包。由于 Python 2.5 是较旧的版本,在 Ubuntu 16.04 的默认软件源中并未提供该版本的支持[^1]。 #### 原因二:依赖关系冲突 即使找到包含 Python 2.5 的自定义 PPA 或其他软件源,也可能因为依赖项不匹配而导致安装失败。例如,某些依赖可能需要特定版本的库文件,而这些库文件在当前系统中并不存在或已被替换为更高版本[^2]。 --- ### 解决方案 以下是几种可行的方法解决此问题: #### 方法一:手动编译安装 Python 2.5 如果确实需要使用 Python 2.5,则可以通过下载其源码并手动编译安装。具体操作如下: 1. 下载 Python 2.5 源码: ```bash wget https://www.python.org/ftp/python/2.5/Python-2.5.tgz ``` 2. 解压并进入解压后的目录: ```bash tar -xvzf Python-2.5.tgz cd Python-2.5 ``` 3. 编译并安装: ```bash ./configure --prefix=/usr/local/python2.5 make sudo make install ``` 完成上述步骤后,可以运行 `/usr/local/python2.5/bin/python` 来启动 Python 2.5 环境[^3]。 #### 方法二:调整软件源以启用旧版 Python 支持 虽然 Ubuntu 16.04 默认不支持 Python 2.5,但可以通过添加旧版存档(Old Releases)或其他社区维护的 PPA 来实现安装。然而需要注意的是,这种方法可能会引入安全风险或兼容性问题。 1. 修改软件源列表: ```bash sudo sed -i 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list ``` 2. 更新软件源缓存: ```bash sudo apt-get update --fix-missing ``` 3. 尝试重新安装 Python 2.5(需确认是否有可用包): ```bash sudo apt-get install python2.5 ``` 注意:此方法的成功率较低,建议仅作为备选方案[^4]。 #### 方法三:隔离环境下的虚拟化部署 为了减少对现有系统的干扰,推荐使用容器技术(如 Docker)或虚拟机创建独立的开发环境,并在此环境中配置所需的 Python 版本。例如: 1. 创建基于 Ubuntu 16.04 的 Docker 镜像; 2. 手动安装 Python 2.5 或切换至更早的操作系统版本(如 Debian Etch),其中仍保留对该版本的支持。 --- ### 注意事项 - **安全性考量**:Python 2.5 属于非常老旧的版本,已停止官方支持多年。继续使用此类版本可能导致严重的安全隐患。 - **替代方案**:评估项目需求,尽可能升级到受支持的 Python 版本(如 Python 2.7 或 Python 3.x)。这不仅能够提高程序稳定性,还能享受更多现代功能和优化性能[^5]。 ---
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值