当前位置: 首页>>技术教程>>正文


由于未满足的依赖性,无法清除完整/启动

ubuntuer 技术教程 , , , 去评论

问题描述

我收到一条错误消息,说明我的/boot已满。由于磁盘已满错误或依赖性错误,尝试清理旧映像文件似乎总是失败。有人可以解释我哪里出错了。

$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run ‘apt-get -f install’ to correct these.
The following packages have unmet dependencies.
 linux-image-extra-3.13.0-44-generic : Depends: linux-image-3.13.0-44-generic but it is not installed
 linux-image-extra-3.13.0-45-generic : Depends: linux-image-3.13.0-45-generic but it is not installed
 linux-image-generic : Depends: linux-image-3.13.0-45-generic but it is not installed
E: Unmet dependencies. Try using -f.

$ ls /boot
abi-3.13.0-32-generic         initrd.img-3.13.0-43-generic
abi-3.13.0-36-generic         lost+found
abi-3.13.0-37-generic         memtest86+.bin
abi-3.13.0-39-generic         memtest86+.elf
abi-3.13.0-40-generic         memtest86+_multiboot.bin
abi-3.13.0-43-generic         System.map-3.13.0-32-generic
config-3.13.0-32-generic      System.map-3.13.0-36-generic
config-3.13.0-36-generic      System.map-3.13.0-37-generic
config-3.13.0-37-generic      System.map-3.13.0-39-generic
config-3.13.0-39-generic      System.map-3.13.0-40-generic
config-3.13.0-40-generic      System.map-3.13.0-43-generic
config-3.13.0-43-generic      vmlinuz-3.13.0-32-generic
grub                          vmlinuz-3.13.0-36-generic
initrd.img-3.13.0-32-generic  vmlinuz-3.13.0-37-generic
initrd.img-3.13.0-36-generic  vmlinuz-3.13.0-39-generic
initrd.img-3.13.0-37-generic  vmlinuz-3.13.0-40-generic
initrd.img-3.13.0-39-generic  vmlinuz-3.13.0-43-generic
initrd.img-3.13.0-40-generic

我用了

kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver

要得到

linux-headers-3.13.0-32
linux-headers-3.13.0-32-generic
linux-headers-3.13.0-36
linux-headers-3.13.0-36-generic
linux-headers-3.13.0-37
linux-headers-3.13.0-37-generic
linux-headers-3.13.0-39
linux-headers-3.13.0-39-generic
linux-headers-3.13.0-40
linux-headers-3.13.0-40-generic
linux-headers-3.13.0-44
linux-headers-3.13.0-44-generic
linux-headers-3.13.0-45
linux-headers-3.13.0-45-generic
linux-image-3.13.0-32-generic
linux-image-3.13.0-36-generic
linux-image-3.13.0-37-generic
linux-image-3.13.0-39-generic
linux-image-3.13.0-40-generic

然后选择要删除的第一张图像

$ sudo apt-get purge linux-image-3.13.0-32-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
 linux-image-extra-3.13.0-32-generic : Depends: linux-image-3.13.0-32-generic but it is not going to be installed
 linux-image-extra-3.13.0-44-generic : Depends: linux-image-3.13.0-44-generic but it is not going to be installed
 linux-image-extra-3.13.0-45-generic : Depends: linux-image-3.13.0-45-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-3.13.0-45-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

最佳解决办法

在这种情况下,我会使用dpkg工具强制删除一些内核包。这不建议常用,有点危险,但在这种情况下,未满足的依赖可能会有所帮助。

首先找到引导系统的内核。当前加载的那个。打开终端(CTRL + ALT + T)并发出以下命令

uname -r

它会显示加载的内核,你不应该尝试删除这个。

然后发出命令

ls /boot 

它将返回所有已安装的图像。选择一个或两个并尝试删除它们。尝试强制删除/清除它们。例如

sudo dpkg --force-all -P linux-image-3.13.0-32-generic

您可以对其他图像执行相同操作,以释放一些空间。

然后,您可以尝试安装缺少的包,或

sudo apt-get install -f 

尝试解决依赖关系。

最后,发出“cleanup old kernels”命令

 sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

上面的命令将删除除当前加载的内核之外的所有内核。

因为你有一个单独的/boot分区,请记住你需要跟踪它的空间并经常清理(频率取决于/boot的空间)

次佳解决办法

这对我在Ubuntu 16.04上有用。

sudo apt autoremove --purge
sudo apt autoremove
sudo apt-get -f install
sudo apt-get upgrade

第三种解决办法

列出所有内核:

dpkg --list 'linux-image*'

显示当前内核:

uname -r

列出所有内核除了当前的一个:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'

确保您当前的内核不在该列表中。

删除所有内核除了当前内核:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge

清除其他东西:

sudo apt-get autoremove

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/3021.html,未经允许,请勿转载。

相关文章