使用 apt-get autoremove 解决缺少依赖项的问题

使用 apt-get autoremove 解决缺少依赖项的问题

我的 Ubuntu 服务器实例的/boot分区目前已达到 100%,我想使用 删除一些未使用/不需要的依赖项sudo apt-get autoremove。但是,似乎缺少一些依赖项,我无法安装这些依赖项,因为 中显然需要这些依赖项/boot,但如前所述,它们已满。我尝试使用sudo apt-get autoremove -f删除并修复依赖项,但似乎它想在删除其他所有内容之前安装依赖项。有没有办法删除未使用的依赖项/包没有安装缺少的依赖项?如果有帮助的话,我在下面附上了我的终端输出。

mkoch@ubuntu:~$ sudo apt-get autoremove -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-generic linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
  linux-headers-generic linux-image-3.13.0-39-generic
  linux-image-extra-3.13.0-39-generic linux-image-generic
Suggested packages:
  fdutils linux-doc-3.13.0 linux-source-3.13.0 linux-tools
The following packages will be REMOVED:
  linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic
  linux-headers-3.13.0-27 linux-headers-3.13.0-27-generic
  linux-headers-3.13.0-29 linux-headers-3.13.0-29-generic
  linux-headers-3.13.0-30 linux-headers-3.13.0-30-generic
  linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
  linux-headers-3.13.0-33 linux-headers-3.13.0-33-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-image-3.13.0-24-generic linux-image-3.13.0-27-generic
  linux-image-3.13.0-29-generic linux-image-3.13.0-30-generic
  linux-image-3.13.0-32-generic linux-image-3.13.0-33-generic
  linux-image-extra-3.13.0-24-generic linux-image-extra-3.13.0-27-generic
  linux-image-extra-3.13.0-29-generic linux-image-extra-3.13.0-30-generic
  linux-image-extra-3.13.0-32-generic linux-image-extra-3.13.0-33-generic
  linux-image-extra-3.13.0-36-generic linux-image-extra-3.13.0-37-generic
The following NEW packages will be installed:
  linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
  linux-image-3.13.0-39-generic linux-image-extra-3.13.0-39-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic
3 upgraded, 4 newly installed, 30 to remove and 91 not upgraded.
12 not fully installed or removed.
Need to get 61.3 MB of archives.
After this operation, 1,488 MB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-3.13.0-39-generic i386 3.13.0-39.66 [14.6 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-extra-3.13.0-39-generic i386 3.13.0-39.66 [37.1 MB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-generic i386 3.13.0.39.46 [1,780 B]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-generic i386 3.13.0.39.46 [2,420 B]
Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-3.13.0-39 all 3.13.0-39.66 [8,892 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-3.13.0-39-generic i386 3.13.0-39.66 [716 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-generic i386 3.13.0.39.46 [2,404 B]
Fetched 61.3 MB in 4min 33s (224 kB/s)                                         
(Reading database ... 349968 files and directories currently installed.)
Removing linux-headers-3.13.0-36-generic (3.13.0-36.63) ...
Removing linux-headers-3.13.0-36 (3.13.0-36.63) ...
Selecting previously unselected package linux-image-3.13.0-39-generic.
(Reading database ... 325045 files and directories currently installed.)
Preparing to unpack .../linux-image-3.13.0-39-generic_3.13.0-39.66_i386.deb ...
Done.
Unpacking linux-image-3.13.0-39-generic (3.13.0-39.66) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.13.0-39-generic_3.13.0-39.66_i386.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-3.13.0-39-generic' to '/boot/vmlinuz-3.13.0-39-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 3.13.0-39-generic /boot/vmlinuz-3.13.0-39-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-39-generic /boot/vmlinuz-3.13.0-39-generic
Selecting previously unselected package linux-image-extra-3.13.0-39-generic.
Preparing to unpack .../linux-image-extra-3.13.0-39-generic_3.13.0-39.66_i386.deb ...
Unpacking linux-image-extra-3.13.0-39-generic (3.13.0-39.66) ...
Preparing to unpack .../linux-generic_3.13.0.39.46_i386.deb ...
Unpacking linux-generic (3.13.0.39.46) over (3.13.0.37.44) ...
Preparing to unpack .../linux-image-generic_3.13.0.39.46_i386.deb ...
Unpacking linux-image-generic (3.13.0.39.46) over (3.13.0.37.44) ...
Selecting previously unselected package linux-headers-3.13.0-39.
Preparing to unpack .../linux-headers-3.13.0-39_3.13.0-39.66_all.deb ...
Unpacking linux-headers-3.13.0-39 (3.13.0-39.66) ...
Selecting previously unselected package linux-headers-3.13.0-39-generic.
Preparing to unpack .../linux-headers-3.13.0-39-generic_3.13.0-39.66_i386.deb ...
Unpacking linux-headers-3.13.0-39-generic (3.13.0-39.66) ...
Preparing to unpack .../linux-headers-generic_3.13.0.39.46_i386.deb ...
Unpacking linux-headers-generic (3.13.0.39.46) over (3.13.0.37.44) ...
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-3.13.0-39-generic_3.13.0-39.66_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我能够按照 flickerfly 的回答解决我的问题询问Ubuntu问题。他的回答如下:

  1. 运行sudo dpkg --list 'linux-image*'查看当前安装的内核。
  2. 运行uname -r查看当前使用的内核。
  3. 运行sudo rm -rf /boot/*-3.2.0-{23,45,49,51,52,53,54,55}-*,将版本号替换为您分区中的版本号/boot,并在花括号中输入所有版本号,除了针对您的当前版本和两个最新版本。
  4. 然后运行sudo apt-get -f install以清理缺失的依赖项。
  5. 运行sudo apt-get autoremove以删除任何额外的依赖项。

再次重申,这只是完整答案,但以上几点提供了flickerfly答案的要点。

相关内容