我有一台运行 Ubuntu 18.04 LTS 的服务器。今天早上我运行了一个apt upgrade
,在运行过程中,服务器断电了。恢复后,我登录并发现有 2 个软件包“未完全安装或删除”。我尝试运行apt-get autoremove
、显式apt-get remove
命令以及在线找到的众多解决方案,我现在记不清了。
似乎没有什么帮助,我无法升级/安装软件包,因为 apt 错误地处理损坏的软件包。它们是内核软件包:
linux-image-4.15.0-50-generic
linux-image-4.15.0-51-generic
以下是输出apt-get autoremove
:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-4.15.0-50-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 8,323 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 144087 files and directories currently installed.)
Removing linux-image-4.15.0-50-generic (4.15.0-50.54) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-50-generic
/etc/kernel/postrm.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 127
dpkg: error processing package linux-image-4.15.0-50-generic (--remove):
installed linux-image-4.15.0-50-generic package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-50-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
手动删除文件后运行一系列apt-get autoremove
和命令似乎已解决问题。apt-get autoclean
.deb