由于内核包问题无法升级

这是一个Ubuntu 14.04 LTS用户。

基本上我跑步时遇到了问题

sudo apt-get update sudo apt-get upgrade 

dpkg返回错误代码,因为Linux内核包3.13.0.57被标记为“未完全安装”:

 Errors were encountered while processing: linux-image-3.13.0.57-generic linux-image-extra-3.13.0-57-generic E: Sub-process /usr/bin/dpkg returned an error code (1) 

我键入uname -r以查看系统内核的当前版本是什么,令人惊讶的是它是3.13.0.57 。 之后我重新启动系统并输入grub列出所有已安装的Linux内核,并看到我有3.8.0-35-generic,所以我启动它以尝试重新安装3.13.0.57版本。 我没有任何线索为什么默认情况下,当3.8.0-35可用时,Ubuntu 14.04会以3.13.0.57启动。

在我用3.8.0成功启动后,我再次列出了所有与dpkg相关的内核,以确保3.13.0-57存在。

 sudo dpkg --list | grep linux-image sudo apt-get purge linux-image-3.13.0.57-generic sudo apt-get purge linux-image-extra-3.13.0-57-generic 

但是额外的图像包无法删除,而纯linux图像可以:

 Errors were encountered while processing: linux-image-extra-3.13.0-57-generic E: Sub-process /usr/bin/dpkg returned an error code (1) 

任何想法如何解决这一问题? 我搜索并发现启动分区上可能缺少空间会导致这类问题,但我认为我的情况有所不同。 我设法手动清除4-5个旧内核,以确保我在启动分区上释放了足够的空间。

编辑1:我看到Ubuntu 14.04.2附带Linux Kernel 3.16.x,但我没有。 我拥有的最新版本是3.8.0-35然后是3.13.0-57。

编辑2:运行sudo apt-get autoremovesudo apt-get dist-upgrade没有帮助。 似乎我无法运行任何升级。 这是sudo apt-get autoremove的日志:

  $ sudo apt-get autoremove Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: linux-image-extra-3.13.0-57-generic 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. 2 not fully installed or removed. After this operation, 152 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 747752 files and directories currently installed.) Removing linux-image-extra-3.13.0-57-generic (3.13.0-57.95) ... depmod: FATAL: could not load /boot/System.map-3.13.0-57-generic: No such file or directory run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic run-parts: executing /etc/kernel/postinst.d/dkms 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic update-initramfs: Generating /boot/initrd.img-3.13.0-57-generic grep: /boot/config-3.13.0-57-generic: No such file or directory run-parts: executing /etc/kernel/postinst.d/pm-utils 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic run-parts: executing /etc/kernel/postinst.d/zz-runlilo 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic Fatal: open /boot/vmlinuz-3.13.0-46-generic.efi.signed: No such file or directory run-parts: /etc/kernel/postinst.d/zz-runlilo exited with return code 1 dpkg: error processing package linux-image-extra-3.13.0-57-generic (--remove): subprocess installed post-removal script returned error exit status 1 Errors were encountered while processing: linux-image-extra-3.13.0-57-generic E: Sub-process /usr/bin/dpkg returned an error code (1) 

我不知道这是什么 – Fatal: open /boot/vmlinuz-3.13.0-46-generic.efi.signed: No such file or directory与删除3.13.0-57有关。

我设法找到问题的解决方案。 然而,如果有同样问题的人挣扎,我决定将其作为答案发布。

问题的原因:

我检查了包的dpkg状态:

 dpkg --status linux-image-3.13.0.57-generic dpkg --status linux-image-extra-3.13.0-57-generic 

输出明确指出包装处于不良状态。 正如我在上面的问题中写的那样,它们“没有完全安装”。

解决方案:

必须从dpkg的状态文件中删除这些软件包的条目才能使apt-get正常运行。 步骤如下:

  1. 如果出现问题,请务必备份状态文件。

    sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.backup

  2. 使用首选文本编辑器打开/var/lib/dpkg/status ,并搜索和删除已损坏软件包的引用。 你不能删除任何其他东西!

  3. 运行sudo apt-get upgrade以确保一切都已修复。

wajig remove linux-headers-3.13.0-57-generic为我工作。

我重新启动,并在3.13.0-57-generic内核上。

但要小心! 备份您的数据。

如果你想升级到新内核版本,你可以通过“linux-image-lts …”软件包手动安装它,通过“apt-get dist-upgrade”

这些故障发生在完全luks加密的Volumens导致/ boot在这些设置中太小。

或许“apt-get autoremove”也有帮助……