Ubuntu – How to avoid update of package linux-firmware creating initrd.img files?

aptkernel

On Ubuntu 14.04 LTS, every attempt to update my linux-firmware package is filling my /boot/ mount point with files named like initrd.img-3.13.0-*-generic, preventing successful update.

kgrittn@Kevin-Desktop:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up linux-firmware (1.127.23) ...
update-initramfs: Generating /boot/initrd.img-3.13.0-106-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-105-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-103-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-101-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-100-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-98-generic
grep: /boot/config-3.13.0-98-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-96-generic
grep: /boot/config-3.13.0-96-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-95-generic
grep: /boot/config-3.13.0-95-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-93-generic
grep: /boot/config-3.13.0-93-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-92-generic
grep: /boot/config-3.13.0-92-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-91-generic
grep: /boot/config-3.13.0-91-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-88-generic
grep: /boot/config-3.13.0-88-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-87-generic
grep: /boot/config-3.13.0-87-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-86-generic
grep: /boot/config-3.13.0-86-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-85-generic
grep: /boot/config-3.13.0-85-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-83-generic
grep: /boot/config-3.13.0-83-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-79-generic
grep: /boot/config-3.13.0-79-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-77-generic
grep: /boot/config-3.13.0-77-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-76-generic
grep: /boot/config-3.13.0-76-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-74-generic
grep: /boot/config-3.13.0-74-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-73-generic
grep: /boot/config-3.13.0-73-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-71-generic
grep: /boot/config-3.13.0-71-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-70-generic
grep: /boot/config-3.13.0-70-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-68-generic
grep: /boot/config-3.13.0-68-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-67-generic
grep: /boot/config-3.13.0-67-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-66-generic
grep: /boot/config-3.13.0-66-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-65-generic
grep: /boot/config-3.13.0-65-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-63-generic
grep: /boot/config-3.13.0-63-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-62-generic
grep: /boot/config-3.13.0-62-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-61-generic
grep: /boot/config-3.13.0-61-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-59-generic
grep: /boot/config-3.13.0-59-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-58-generic
grep: /boot/config-3.13.0-58-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-57-generic
grep: /boot/config-3.13.0-57-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-55-generic
grep: /boot/config-3.13.0-55-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-53-generic
grep: /boot/config-3.13.0-53-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-52-generic
grep: /boot/config-3.13.0-52-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-51-generic
grep: /boot/config-3.13.0-51-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-49-generic
grep: /boot/config-3.13.0-49-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-48-generic
grep: /boot/config-3.13.0-48-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-46-generic
grep: /boot/config-3.13.0-46-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-45-generic
grep: /boot/config-3.13.0-45-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-44-generic
grep: /boot/config-3.13.0-44-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-43-generic
grep: /boot/config-3.13.0-43-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-40-generic
grep: /boot/config-3.13.0-40-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-39-generic
grep: /boot/config-3.13.0-39-generic: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.13.0-37-generic
grep: /boot/config-3.13.0-37-generic: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-37-generic with 1.
dpkg: error processing package linux-firmware (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)

The files are about 19MB each.

Initially it only got to initrd.img-3.13.0-51-generic and failed, I removed some old kernel versions and it now gets to initrd.img-3.13.0-39-generic before failing. I'm uncomfortable removing any more versions without being sure that freeing some specific amount of space will allow success.


NOTE:
(I would put this as an answer, except that the question is locked in a way that prevents it.)

Never delete old OS versions from the /boot/ directory directly, in spite of advice you may find elsewhere to do so. That may work for years (or decades) and then suddenly cause the problem described above. Each OS version, whether or not in use, has one or more related packages, and this may cause the problem described here (or other problems, too???).

I have only seen it on an update of the linux-firmware package, but I have no way of knowing what other package maintenance operations might feel free to re-create boot files which you have deleted — running you out of space. I suspect that creating incomplete boot images in such a situation is considered a "feature", although I think it is a bad design choice. A message mentioning a package name and the fact that files required by the package are missing would be great, and skipping generation of the initrd.img-* file for a version if there are no files for the version would also be excellent. (Ideally both, but either would have saved hours of frustration.)

Best Answer

The initrd.img file is the initial ramdisk. It is a fundamental component of your OS and is needed to boot the system. Each kernel has it's own initrd.img file.

I would definately delete all your old kernels. First, find out which kernel you are currently running;

uname -r

Then, uninstall all the old kernels and old headers;

sudo apt-get remove linux-image-<kernel number>
sudo apt-get remove linux-headers-<kernel number>

For example;

sudo apt-get remove linux-image-3.13.0-106-generic

There is no use what-so-ever in keeping those older kernels, especially as you have ran out of disk space. I only ever keep my current kernel and the last one.

After deleting them, your future updates should work again as you will have freed a lot of space.

Related Question