Update fills /boot with old incorrect versions
Whenever I update Linux, for example from 4.4.0.65 to 4.4.0.66 :
- the Software Update tool downloads about 40 previous versions of
initrd.img-4.4.0.XX-generic
before trying the newest version -
/boot
fills up - the current version does not load, as boot is out of room
- the system is (sometimes) configured to a version that does not exist, and tries to boot it on startup
I have dealt with this for a long time, since version 29.
The only workaround I have found takes me an hour each update. I open command line during the update, and delete versions as they are downloaded. Eventually the update tool is satisfied that it has downloaded all previous versions, downloads the latest version, and configures the system.
Here is the output from 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
Here are the errors from '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)
Solution 1:
For me, this was a problem with update-initramfs and old, stale files not getting removed from /var/lib/initramfs-tools during previous kernel upgrades (probably due to apt previously erroring out for one reason or another).
cd /var/lib/initramfs-tools
Delete files for old kernel versions (don't delete the one for the current kernel version, obviously).
cd /boot
Delete old versions of initrd in /boot.
Then run:
/usr/sbin/update-initramfs -u -k all
This should succeed and only create (or update) an initrd file in /boot for your current kernel version.
Solution 2:
The initrd.img
files are not downloaded, they are generated since you have the corresponding kernel (linux-image
) packages installed: Apt notices that the kernel package is installed but the corresponding initrd is missing, so it regenerates the initrd.
To stop it, uninstall the kernel packages with sudo apt remove linux-image-4.2.0-35-generic
(and similarly for other versions). That is the proper way to uninstall an old kernel.