![如何修复旧内核的配置问题以使 Ubuntu 能够升级?](https://linux22.com/image/1154581/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%E6%97%A7%E5%86%85%E6%A0%B8%E7%9A%84%E9%85%8D%E7%BD%AE%E9%97%AE%E9%A2%98%E4%BB%A5%E4%BD%BF%20Ubuntu%20%E8%83%BD%E5%A4%9F%E5%8D%87%E7%BA%A7%EF%BC%9F.png)
我正在尝试在虚拟机 VirtualBox 上升级我的 Ubuntu 16.04。但是当运行以下代码时:
sudo apt-get upgrade
我收到以下错误消息:
(Reading database ... 248247 files and directories currently
installed.) Removing linux-image-extra-4.4.0-109-generic
(4.4.0-109.132) ... run-parts: executing
/etc/kernel/postinst.d/apt-auto-removal 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic run-parts: executing
/etc/kernel/postinst.d/initramfs-tools 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic update-initramfs: Generating
/boot/initrd.img-4.4.0-109-generic run-parts: executing
/etc/kernel/postinst.d/pm-utils 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic run-parts: executing
/etc/kernel/postinst.d/unattended-upgrades 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic run-parts: executing
/etc/kernel/postinst.d/update-notifier 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic run-parts: executing
/etc/kernel/postinst.d/vboxadd 4.4.0-109-generic
/boot/vmlinuz-4.4.0-109-generic run-parts: failed to exec
/etc/kernel/postinst.d/vboxadd: Exec format error run-parts:
/etc/kernel/postinst.d/vboxadd exited with return code 1 dpkg: error
processing package linux-image-extra-4.4.0-109-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
linux-image-extra-4.4.0-109-generic E: Sub-process /usr/bin/dpkg
returned an error code (1)
我不知道如何修复 109 个文件的配置文件。但这是输出uname -r
:
4.4.0-116-generic
以下是运行时可用版本的完整列表dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r)
ri linux-image-4.4.0-109-generic 4.4.0-109.132
amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-112-generic 4.4.0-112.135
amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
我似乎无法在此网站上找到解决方案,因为我错误地应用了解决方案,导致问题变得更加严重。非常感谢您帮助我修复机器。
答案1
根据这篇文章(Apt 无法删除部分安装的内核,也无法安装任何其他软件包),
我创建了状态文件的备份,以防出现问题:
sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.backup
我打开
/var/lib/dpkg/status
并gedit
搜索并删除了损坏包的引用。以下是验证此类包的代码:(状态会告诉您它们是否真的损坏了):dpkg --status linux-image-4.4.0-109-generic
dpkg --status linux-image-extra-4.4.0-109-generic
我跑去
sudo apt-get update
确保sudo apt-get upgrade
问题已得到解决。