Apt无法删除部分安装的内核,无法安装任何其他软件包
看似部分内核升级后,Apt无法升级或安装新软件包。 我已经尝试了apt-get purge -f linux-image-extra-3.19.0-22-generic
,它失败并出现非常相似的错误消息。 机器也会在启动时崩溃到最新的内核版本(在grub中默认),但以前的版本工作正常。
$ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be REMOVED: linux-image-3.19.0-22-generic linux-image-extra-3.19.0-22-generic The following packages will be upgraded: linux-cloud-tools-common 1 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. 2 not fully installed or removed. Need to get 0 B/24.3 kB of archives. After this operation, 208 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 453815 files and directories currently installed.) Removing linux-image-extra-3.19.0-22-generic (3.19.0-22.22) ... depmod: FATAL: could not load /boot/System.map-3.19.0-22-generic: No such file or directory run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic run-parts: executing /etc/kernel/postinst.d/dkms 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic update-initramfs: Generating /boot/initrd.img-3.19.0-22-generic grep: /boot/config-3.19.0-22-generic: No such file or directory depmod: WARNING: could not open /tmp/mkinitramfs_6gldfB/lib/modules/3.19.0-22-generic/modules.order: No such file or directory depmod: WARNING: could not open /tmp/mkinitramfs_6gldfB/lib/modules/3.19.0-22-generic/modules.builtin: No such file or directory run-parts: executing /etc/kernel/postinst.d/pm-utils 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic Generating grub configuration file ... ERROR: cannot determine partition label for rootfs /dev/sda9 run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1 dpkg: error processing package linux-image-extra-3.19.0-22-generic (--remove): subprocess installed post-removal script returned error exit status 1 Removing linux-image-3.19.0-22-generic (3.19.0-22.22) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic update-initramfs: Deleting /boot/initrd.img-3.19.0-22-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.19.0-22-generic /boot/vmlinuz-3.19.0-22-generic Generating grub configuration file ... ERROR: cannot determine partition label for rootfs /dev/sda9 run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1 Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.19.0-22-generic.postrm line 328. dpkg: error processing package linux-image-3.19.0-22-generic (--remove): subprocess installed post-removal script returned error exit status 1 Errors were encountered while processing: linux-image-extra-3.19.0-22-generic linux-image-3.19.0-22-generic E: Sub-process /usr/bin/dpkg returned an error code (1)
我需要再次工作并进入可以安装未来内核的状态。 正确清除3.19.0-22内核会很好但不必要。 请随时询问更多信息,并提前感谢
–Edits–
0x450的答案适用于任何非内核相关的包。 内核和grub更新将apt和dpkg返回到损坏状态。 我注意到这个反复出现的错误消息:
Generating grub configuration file ... ERROR: cannot determine partition label for rootfs /dev/sda9
这可能是与grub配置文件相关的问题吗?
sudo apt-get install --reinstall linux-image-extra-3.19.0-22-generic
导致一个非常相似的错误(可以在这里查看)
sudo dpkg --configure -a
创建此错误
sudo apt-get purge linux-image-extra-3.19.0-22-generic
创建此错误
我遇到了完全相同的问题,但破碎的内核包是版本3.13.0.57。
检查问题:
检查包的dpkg status
:
dpkg --status linux-image-3.19.0-22-generic dpkg --status linux-image-extra-3.19.0-22-generic
如果输出声明软件包处于错误状态,即安装了一半或未完全安装 ,这意味着它们分别破坏了apt-get
和dpkg
。
解决方案:
必须从dpkg
的状态文件中手动删除受感染内核包的条目,以便apt-get
和dpkg
本身再次正常运行。 步骤如下:
-
确保创建状态文件的备份以防万一出错。
sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.backup
-
使用首选文本编辑器打开
/var/lib/dpkg/status
,并仅搜索和删除已损坏软件包的引用。 你不能删除任何其他东西! -
运行
sudo apt-get update
和sudo apt-get upgrade
以确保一切都已修复。 -
此步骤是可选的,因为不再从程序包管理器跟踪程序包,但是如果需要,可以通过删除它们来释放一些磁盘空间。 您可以安全地手动删除
/boot
和/usr/src
损坏的内核包的所有条目,但要非常小心 。 请务必仅触摸与您的案例中的3.19.0-22版本对应的文件/文件夹。
根本原因
根问题似乎是缺少/boot/System.map-3.19.0-22-generic
,这会阻止重新配置/删除数据包。
建议的解决方案
我最初的建议是sudo apt-get install --reinstall linux-image-extra-3.19.0-22-generic
由于这显然失败了(“无法配置半安装”),我建议这样做更有力 ,例如使用以下选项
sudo dpkg --remove --force-remove-reinstreq linux-image-extra-3.19.0-22-generic
该建议基于这个答案。
替代方案:手动修理?
或者,您也可以尝试手动修复该文件? 也许它在尝试重新安装时被apt-get解压缩? 我现在在我的系统上复制有点困难
我想你应该跑
sudo dpkg --configure -a
接着是已经提到的内容:
sudo apt-get purge linux-image-extra-3.19.0-22-generic
事实certificate问题是由grub-mkconfig崩溃引起的错误消息Generating grub configuration file ... ERROR: cannot determine partition label for rootfs /dev/sda9
(sda9持有我的fs root)。
Apt崩溃,因为当它试图安装新内核时,它运行grub-mkconfig将它们添加到启动菜单。 这实际上不是apt的问题,而是grub。
我通过重新安装ubuntu并使用ext3而不是ext4来修复包含我的文件系统根目录的分区。 我的主目录仍在其自己的ext4分区中,因此它似乎没有受到影响。
0x450的答案很适合作为临时修复,以便可以再次使用apt。 但它并没有解决根本问题。
您可以使用remove而不是purge,然后升级内核,并在终端中输入:
sudo apt-get -f remove linux-image-extra-3.19.0-22-generic
然后删除sources.list文件,并输入设置并更新并孵化所有chanoical列表并再次关闭它。
然后重新安装最新的内核,并在终端中输入:
sudo apt-get install linux-amd64_ linux-efi sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade sudo apt-get install aptitude sudo aptitude linux-efi
它可能会以这种方式工作。