如何清理混乱的 apt-get?

如何清理混乱的 apt-get?

问题:今天早上我想在我的服务器上执行 dist-upgrade。
我得到的结果是:

apt-get dist-upgrade
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.5.0-32-generic : Depends: linux-image-3.5.0-32-generic but it is not installed
 linux-image-generic : Depends: linux-image-3.5.0-32-generic but it is not installed
E: Unmet dependencies. Try using -f.

之后我尝试安装 linux-image-3.5.0-32-generic,发生了以下情况:

apt-get install linux-image-3.5.0-32-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.5.0-22 linux-headers-3.5.0-22-generic linux-headers-3.5.0-23
  linux-headers-3.5.0-23-generic linux-headers-3.5.0-25
  linux-headers-3.5.0-25-generic linux-headers-3.5.0-26
  linux-headers-3.5.0-26-generic linux-headers-3.5.0-27
  linux-headers-3.5.0-27-generic linux-headers-3.5.0-28
  linux-headers-3.5.0-28-generic linux-headers-3.5.0-30
  linux-headers-3.5.0-30-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  fdutils linux-doc-3.5.0 linux-source-3.5.0 linux-tools
The following NEW packages will be installed:
  linux-image-3.5.0-32-generic
0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded.
8 not fully installed or removed.
Need to get 12.0 MB of archives.
After this operation, 32.7 MB of additional disk space will be used.
Get:1 http://ch.archive.ubuntu.com/ubuntu/ quantal-updates/main linux-image-3.5.0-32-generic amd64 3.5.0-32.53 [12.0 MB]
Fetched 12.0 MB in 5s (2,307 kB/s)                       
(Reading database ... 316189 files and directories currently installed.)
Unpacking linux-image-3.5.0-32-generic (from .../linux-image-3.5.0-32-generic_3.5.0-32.53_amd64.deb) ...
Done.
dpkg: error processing /var/cache/apt/archives/linux-image-3.5.0-32-generic_3.5.0-32.53_amd64.deb (--unpack):
 cannot copy extracted data for './boot/System.map-3.5.0-32-generic' to '/boot/System.map-3.5.0-32-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.5.0-32-generic /boot/vmlinuz-3.5.0-32-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.5.0-32-generic /boot/vmlinuz-3.5.0-32-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-3.5.0-32-generic_3.5.0-32.53_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@zotac:~# 

我还剩下 250 GB 的空间,但启动分区已满 95%。
但现在我无法再使用 apt-get,因为它卡在无法安装的软件包上。

此外,apt-get autoremove 和 apt-get clean 没有帮助。

我该如何重置 apt 以消除此错误?那么我可以删除旧的 linux-images 并安装新的吗?

答案1

看起来您安装了大量旧内核(headers/devel),它们填满了/boot分区。

运行dpkg -l | grep linux-image并检查列表,找出您不再需要的内核。运行apt-get purge删除不再需要的内核,删除所有您不想要的内核。

注意:通常最好保留至少 2 个内核,以防 1 个内核损坏且无法启动。

由于您现在有更多空间,/boot您可以apt-get install linux-image-3.5.0-32-generic --reinstall安装最新的 12.10 内核。如果成功,您可以运行dist-upgrade

相关内容