我的服务器上有几个损坏的 Ubuntu 安装。我就是无法摆脱它们。purge
和autoremove
不起作用。它还阻止我使用 安装新软件包apt-get install
。安装失败,因为它首先删除失败。
root@pxeserver:/boot# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-extra-3.16.0-34-generic linux-image-extra-3.16.0-37-generic
linux-image-extra-3.16.0-38-generic linux-image-extra-3.16.0-41-generic
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
6 not fully installed or removed.
After this operation, 467 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 114203 files and directories currently installed.)
Removing linux-image-extra-3.16.0-34-generic (3.16.0-34.47~14.04.1) ...
depmod: FATAL: could not load /boot/System.map-3.16.0-34-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.16.0-34-generic /boot/vmlinuz-3.16.0-34-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.16.0-34-generic /boot/vmlinuz-3.16.0-34-generic
update-initramfs: Generating /boot/initrd.img-3.16.0-34-generic
grep: /boot/config-3.16.0-34-generic: No such file or directory
WARNING: missing /lib/modules/3.16.0-34-generic
Device driver support needs thus be built-in linux image!
depmod: ERROR: could not open directory /lib/modules/3.16.0-34-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_BSLxsR/lib/modules/3.16.0-34-generic/modules.order: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_BSLxsR/lib/modules/3.16.0-34-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.16.0-34-generic /boot/vmlinuz-3.16.0-34-generic
run-parts: executing /etc/kernel/postinst.d/zz-extlinux 3.16.0-34-generic /boot/vmlinuz-3.16.0-34-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.16.0-41-generic...
P: Writing config for /boot/vmlinuz-3.16.0-33-generic...
P: Installing debian theme... done.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.16.0-34-generic /boot/vmlinuz-3.16.0-34-generic
/etc/kernel/postinst.d/zz-update-grub: 22: /etc/kernel/postinst.d/zz-update-grub: Syntax error: "fi" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
dpkg: error processing package linux-image-extra-3.16.0-34-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.16.0-37-generic (3.16.0-37.51~14.04.1) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.16.0-37-generic /boot/vmlinuz-3.16.0-37-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.16.0-37-generic /boot/vmlinuz-3.16.0-37-generic
update-initramfs: Generating /boot/initrd.img-3.16.0-37-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.16.0-37-generic /boot/vmlinuz-3.16.0-37-generic
run-parts: executing /etc/kernel/postinst.d/zz-extlinux 3.16.0-37-generic /boot/vmlinuz-3.16.0-37-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.16.0-41-generic...
P: Writing config for /boot/vmlinuz-3.16.0-33-generic...
P: Installing debian theme... done.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.16.0-37-generic /boot/vmlinuz-3.16.0-37-generic
/etc/kernel/postinst.d/zz-update-grub: 22: /etc/kernel/postinst.d/zz-update-grub: Syntax error: "fi" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
dpkg: error processing package linux-image-extra-3.16.0-37-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.16.0-38-generic (3.16.0-38.52~14.04.1) ...
depmod: FATAL: could not load /boot/System.map-3.16.0-38-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.16.0-38-generic /boot/vmlinuz-3.16.0-38-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.16.0-38-generic /boot/vmlinuz-3.16.0-38-generic
update-initramfs: Generating /boot/initrd.img-3.16.0-38-generic
grep: /boot/config-3.16.0-38-generic: No such file or directory
WARNING: missing /lib/modules/3.16.0-38-generic
Device driver support needs thus be built-in linux image!
depmod: ERROR: could not open directory /lib/modules/3.16.0-38-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_VP711p/lib/modules/3.16.0-38-generic/modules.order: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_VP711p/lib/modules/3.16.0-38-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.16.0-38-generic /boot/vmlinuz-3.16.0-38-generic
run-parts: executing /etc/kernel/postinst.d/zz-extlinux 3.16.0-38-generic /boot/vmlinuz-3.16.0-38-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.16.0-41-generic...
P: Writing config for /boot/vmlinuz-3.16.0-33-generic...
P: Installing debian theme... done.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.16.0-38-generic /boot/vmlinuz-3.16.0-38-generic
/etc/kernel/postinst.d/zz-update-grub: 22: /etc/kernel/postinst.d/zz-update-grub: Syntax error: "fi" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
dpkg: error processing package linux-image-extra-3.16.0-38-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.16.0-41-generic (3.16.0-41.57~14.04.1) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.16.0-41-generic /boot/vmlinuz-3.16.0-41-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.16.0-41-generic /boot/vmlinuz-3.16.0-41-generic
update-initramfs: Generating /boot/initrd.img-3.16.0-41-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.16.0-41-generic /boot/vmlinuz-3.16.0-41-generic
run-parts: executing /etc/kernel/postinst.d/zz-extlinux 3.16.0-41-generic /boot/vmlinuz-3.16.0-41-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.16.0-41-generic...
P: Writing config for /boot/vmlinuz-3.16.0-33-generic...
P: Installing debian theme... done.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.16.0-41-generic /boot/vmlinuz-3.16.0-41-generic
/etc/kernel/postinst.d/zz-update-grub: 22: /etc/kernel/postinst.d/zz-update-grub: Syntax error: "fi" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
dpkg: error processing package linux-image-extra-3.16.0-41-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
linux-image-extra-3.16.0-34-generic
linux-image-extra-3.16.0-37-generic
linux-image-extra-3.16.0-38-generic
linux-image-extra-3.16.0-41-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
对每个 linux-image-extra-* 包尝试此操作:
dpkg --purge --force-depends linux-image-extra-3.16.0-34-generic
如果这不起作用,那么您可以尝试通过使用以下方法生成丢失的文件来克服“错误”和“严重”日志
touch /boot/System.map-3.16.0-34-generic
答案2
通过 重新安装软件包有帮助吗sudo apt-get install --reinstall
?它将安装相应的 linux-image 软件包作为依赖项,之后您可以通过 用 linux-image-extra 软件包清除这些依赖项sudo apt-get purge
。