每当我更新 Linux 时,例如从 4.4.0.65 到 4.4.0.66:
initrd.img-4.4.0.XX-generic
在尝试最新版本之前,软件更新工具会下载大约 40 个以前的版本/boot
填上- 当前版本无法加载,因为启动空间不足
- 系统(有时)配置为不存在的版本,并在启动时尝试启动它
我已经处理这个问题很长时间了,从第 29 版开始。
我发现的唯一解决方法是每次更新都要花一个小时。我在更新过程中打开命令行,并在下载版本时删除它们。最终,更新工具会确认已下载所有以前的版本,然后下载最新版本并配置系统。
以下是dpkg -l | grep linux-image
rc linux-image-3.19.0-15-generic 3.19.0-15.15 amd64 Linux kernel image for version 3.19.0 on 64 bit x86 SMP
rc linux-image-4.2.0-34-generic 4.2.0-34.39 amd64 Linux kernel image for version 4.2.0 on 64 bit x86 SMP
ii linux-image-4.2.0-35-generic 4.2.0-35.40 amd64 Linux kernel image for version 4.2.0 on 64 bit x86 SMP
ii linux-image-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-22-generic 4.4.0-22.40 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-28-generic 4.4.0-28.47 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-31-generic 4.4.0-31.50 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-34-generic 4.4.0-34.53 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-36-generic 4.4.0-36.55 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-38-generic 4.4.0-38.57 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-42-generic 4.4.0-42.62 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-43-generic 4.4.0-43.63 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-45-generic 4.4.0-45.66 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-47-generic 4.4.0-47.68 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-51-generic 4.4.0-51.72 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-53-generic 4.4.0-53.74 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
iF linux-image-4.4.0-57-generic 4.4.0-57.78 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-59-generic 4.4.0-59.80 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-62-generic 4.4.0-62.83 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-63-generic 4.4.0-63.84 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-64-generic 4.4.0-64.85 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-65-generic 4.4.0-65.86 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
iF linux-image-4.4.0-66-generic 4.4.0-66.87 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-3.19.0-15-generic 3.19.0-15.15 amd64 Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP
rc linux-image-extra-4.2.0-34-generic 4.2.0-34.39 amd64 Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii linux-image-extra-4.2.0-35-generic 4.2.0-35.40 amd64 Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-22-generic 4.4.0-22.40 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-28-generic 4.4.0-28.47 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-31-generic 4.4.0-31.50 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-34-generic 4.4.0-34.53 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-36-generic 4.4.0-36.55 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-38-generic 4.4.0-38.57 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-42-generic 4.4.0-42.62 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-43-generic 4.4.0-43.63 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-45-generic 4.4.0-45.66 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-47-generic 4.4.0-47.68 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-51-generic 4.4.0-51.72 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-53-generic 4.4.0-53.74 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-extra-4.4.0-57-generic 4.4.0-57.78 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-59-generic 4.4.0-59.80 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-62-generic 4.4.0-62.83 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-63-generic 4.4.0-63.84 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-64-generic 4.4.0-64.85 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iF linux-image-extra-4.4.0-65-generic 4.4.0-65.86 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-extra-4.4.0-66-generic 4.4.0-66.87 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-generic 4.4.0.66.70 amd64 Generic Linux kernel image
以下是“sudo apt-get autoremove”的错误
Setting up linux-firmware (1.157.8) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-65-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-42-generic
Setting up linux-image-4.4.0-66-generic (4.4.0-66.87) ...
Internal Error: Could not find image (/boot/vmlinuz-4.4.0-66-generic)
dpkg: error processing package linux-image-4.4.0-66-generic (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-66-generic:
linux-image-extra-4.4.0-66-generic depends on linux-image-4.4.0-66-generic; however:
Package linux-image-4.4.0-66-generic is not configured yet.
dpkg: error processing package linux-image-extra-4.4.0-66-generic (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
linux-image-generic depends on linux-image-4.4.0-66-generic; however:
Package linux-image-4.4.0-66-generic is not configured yet.
linux-image-generic depends on linux-image-extra-4.4.0-66-generic; however:
Package linux-image-extra-4.4.0-66-generic is not configured yet.
dpkg: error processing package linux-image-generic (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
linux-generic depends on linux-image-generic (= 4.4.0.66.70); however:
Package linux-image-generic is not configured No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure. No apport report written because MaxReports is reached already yet.
dpkg: error processing package linux-generic (--configure):
dependency problems - leaving unconfigured
Setting up linux-image-extra-4.4.0-65-generic (4.4.0-65.86) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-65-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-65-generic /boot/vmlinuz-4.4.0-65-generic
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-65-generic
Found initrd image: /boot/initrd.img-4.4.0-65-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done
Errors were encountered while processing:
linux-image-4.4.0-66-generic
linux-image-extra-4.4.0-66-generic
linux-image-generic
linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
对我来说,这是 update-initramfs 的问题,在之前的内核升级过程中,旧的、陈旧的文件没有从 /var/lib/initramfs-tools 中删除(可能是由于 apt 之前由于某种原因出现错误)。
cd /var/lib/initramfs-tools
删除旧内核版本的文件(显然,不要删除当前内核版本的文件)。
cd /boot
删除 /boot 中旧版本的 initrd。
然后运行:
/usr/sbin/update-initramfs -u -k all
这应该会成功,并且只会在 /boot 中为您当前的内核版本创建(或更新)一个 initrd 文件。
答案2
这些initrd.img
文件不是下载的,而是由于您linux-image
安装了相应的内核()包而生成的:Apt 注意到内核包已安装,但缺少相应的 initrd,因此它重新生成 initrd。
要停止此操作,请使用卸载内核软件包sudo apt remove linux-image-4.2.0-35-generic
(其他版本也类似)。这是卸载旧内核的正确方法。
答案3
我的问题是由于使用“sudo rm”从启动中错误删除文件而引起的。
第一个问题是旧软件包被自动加载并填充 /boot。要自动删除旧软件包,我可以使用“sudo apt-get autoremove”。
但是我仍然无法升级,并出现以下错误:
处理时遇到错误:linux-image-4.4.0-66-generic linux-image-extra-4.4.0-66-generic linux-image-generic linux-generic E:子进程 /usr/bin/dpkg 返回错误代码 (1)
我在这里读到过类似的问题:由于内核包问题,无法 apt 升级并按照如下答案部分的步骤进行操作...
我尝试了“wajig remove linux-headers-4.4.0-66.generic”和“sudo apt-get upgrade”,但它仍然返回:处理时遇到错误:linux-image-4.4.0-66-generic linux-image-extra-4.4.0-66-generic linux-image-generic
因此,我备份了 /var/lib/dpkg/status,然后在 gedit 中打开了 /var/lib/dpkg/status。
我在 /var/lib/dpkg/status 中搜索了“4.4.0-66”,并删除了以“Package: linux-image-4.4.0-66-generic”开头的整个部分,因为该部分的第二行显示“Status: install ok half-configured”。
此后,“sudo apt-get upgrade”能够正确安装最新的内核。