需要在启动时释放空间以进行更新,但由于未满足依赖关系而无法清除内核

需要在启动时释放空间以进行更新,但由于未满足依赖关系而无法清除内核

我的问题:

我在尝试时收到此消息安装更新

升级需要磁盘“/boot”上总共 176 M 的可用空间。请在“/boot”上至少释放 176 M 的额外磁盘空间。使用“sudo apt-get clean”清空垃圾并删除以前安装的临时软件包。

关于我的系统:

结果cat /etc/fstab如下:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/nvme0n1p2 during installation
UUID=30d084a8-283a-4450-b101-c1c60819364a /boot           ext2    defaults        0       2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=B6F8-3AD2  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

结果df -h如下:

Filesystem                   Size  Used Avail Use% Mounted on
udev                          12G     0   12G   0% /dev
tmpfs                        2,4G  9,8M  2,4G   1% /run
/dev/mapper/ubuntu--vg-root  894G   95G  754G  12% /
tmpfs                         12G  439M   12G   4% /dev/shm
tmpfs                        5,0M  4,0K  5,0M   1% /run/lock
tmpfs                         12G     0   12G   0% /sys/fs/cgroup
/dev/nvme0n1p2               473M  465M     0 100% /boot
/dev/nvme0n1p1               511M  3,4M  508M   1% /boot/efi
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        2,4G   88K  2,4G   1% /run/user/1000

结果uname -a看起来如下:

Linux ##### 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

结果dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'看起来如下:

linux-headers-4.10.0-27
linux-headers-4.10.0-27-generic
linux-headers-4.4.0-78
linux-headers-4.4.0-78-generic-tuxonice
linux-headers-4.4.0-83
linux-headers-4.4.0-83-generic-tuxonice
linux-headers-4.8.0-36
linux-headers-4.8.0-36-generic
linux-headers-4.8.0-53
linux-headers-4.8.0-53-generic
linux-headers-4.8.0-54
linux-headers-4.8.0-54-generic
linux-headers-4.8.0-56
linux-headers-4.8.0-56-generic
linux-image-4.4.0-78-generic-tuxonice
linux-image-4.4.0-83-generic-tuxonice
linux-image-4.8.0-36-generic
linux-image-4.8.0-53-generic
linux-image-4.8.0-54-generic
linux-image-4.8.0-56-generic
linux-image-extra-4.4.0-78-generic-tuxonice
linux-image-extra-4.8.0-36-generic
linux-image-extra-4.8.0-53-generic
linux-image-extra-4.8.0-54-generic
linux-image-extra-4.8.0-56-generic
linux-libc-dev:amd64
linux-signed-image-4.8.0-53-generic
linux-signed-image-4.8.0-54-generic
linux-signed-image-4.8.0-56-generic

我尝试过的:

来自类似这样的帖子,例如: 如何在 /boot 中释放更多空间?

我认为,我可以删除以下图像:

linux-image-4.8.0-36-generic
linux-image-4.8.0-53-generic
linux-image-4.8.0-54-generic

使用以下命令:sudo apt-get purge linux-image-4.8.0-{36,53,54}-generic

我现在有以下问题:

  1. 结果sudo apt-get purge linux-image-4.8.0-{36,53,54}-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-4.10.0-28-generic : Depends: linux-image-4.10.0-28-generic but it is not going to be installed
 linux-image-extra-4.8.0-36-generic : Depends: linux-image-4.8.0-36-generic but it is not going to be installed
 linux-image-extra-4.8.0-53-generic : Depends: linux-image-4.8.0-53-generic but it is not going to be installed
 linux-image-extra-4.8.0-54-generic : Depends: linux-image-4.8.0-54-generic but it is not going to be installed
 linux-image-generic-hwe-16.04 : Depends: linux-image-4.10.0-28-generic but it is not going to be installed
 linux-signed-image-4.10.0-28-generic : Depends: linux-image-4.10.0-28-generic (= 4.10.0-28.32~16.04.2) but it is not going to be installed
 linux-signed-image-4.8.0-53-generic : Depends: linux-image-4.8.0-53-generic (= 4.8.0-53.56~16.04.1) but it is not going to be installed
 linux-signed-image-4.8.0-54-generic : Depends: linux-image-4.8.0-54-generic (= 4.8.0-54.57~16.04.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

为什么我想删除图片时必须安装某些东西?我该如何删除图片?因为在我输入命令后,图片似乎还在那里dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'

  1. 我是否还必须删除带有linux-headers-*和 的文件linux-signed-image-*?例如,如果我删除linux-image-4.8.0-36-generic,那么我可能不需要
linux-headers-4.8.0-36
linux-headers-4.8.0-36-generic
linux-image-extra-4.8.0-36-generic
  1. Ubuntu 不应该自动处理不需要的内核的删除吗?或者我必须手动执行此操作的原因是什么?我之前在另一台机器上使用过 Ubuntu 几年,从来没有这样做过。现在我买了一台新机器,几个月后突然遇到了这个问题。

    我必须加密我的硬盘。这可能是原因吗?

更新:

我运行了以下命令:

  • sudo apt-get -f install
  • sudo apt-get clean
  • sudo apt autoremove -f

但都导致了这个错误:

Unpacking linux-image-4.10.0-28-generic (4.10.0-28.32~16.04.2) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.10.0-28-generic_4.10.0-28.32~16.04.2_amd64.deb (--unpack):
 cannot copy extracted data for './boot/System.map-4.10.0-28-generic' to '/boot/System.map-4.10.0-28-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
                                                                          

    dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.10.0-28-generic /boot/vmlinuz-4.10.0-28-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.10.0-28-generic /boot/vmlinuz-4.10.0-28-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-4.10.0-28-generic_4.10.0-28.32~16.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

为什么当我想删除图像时必须安装一些东西?

您无需安装任何东西。除非您同时删除依赖于这些图像的图像,否则它不会让您删除这些图像。例如,您需要使用:

$ sudo apt-get purge linux-headers-4.4.33-040433* linux-headers-4.4.33-040433-generic* linux-image-4.4.33-040433-generic*
The following packages will be REMOVED:
  linux-headers-4.4.33-040433* linux-headers-4.4.33-040433-generic*
  linux-image-4.4.33-040433-generic*

为了避免这种手动工作,请尝试我的bash 脚本它可以自动完成整个过程。是的,这可能是一个无耻的插件,但我花了很多时间进行开发和微调,所以希望看到尽可能多的人使用它。

我是否还必须删除带有 linux-headers-* 和 linux-signed-image-* 的文件?

是的,正如上一节所回答的那样。

Ubuntu 不应该自动处理不需要的内核的删除吗?或者我必须手动执行此操作的原因是什么?

当您使用以下命令时,Ubuntu 会自动删除它自动安装的内核:

sudo apt-get autoremove

如果您使用如下技术手动安装内核:如何将内核更新到最新的主线版本?那么您还必须手动删除内核。

我必须加密我的硬盘。这可能是原因吗?

不。但我不会加密我的硬盘。

答案2

  1. 当您尝试获取新内核时,安装由于 /boot 空间不足而失败,您首先必须解决此安装不完整的问题,如错误所述,通过运行开始:

    sudo apt-get -f install

    然后删除旧内核

  2. apt 应该处理这个问题

  3. 您可以使用以下命令删除旧内核:

    sudo apt-get autoremove --purge

    更多信息:移除旧内核

相关内容