3

Here are the contents of /boot:

drwxr-xr-x  5 root root     3072 Apr 18 09:10 .
drwxr-xr-x 26 root root     4096 Mar 22 15:43 ..
-rw-r--r--  1 root root   217495 Jan 17 05:59 config-4.15.0-76-generic
-rw-r--r--  1 root root   217457 Feb 28 02:45 config-4.15.0-91-generic
drwxr-xr-x  3 root root     4096 Dec 31  1969 efi
drwxr-xr-x  5 root root     1024 Mar 22 15:50 grub
-rw-r--r--  1 root root 60196828 Apr 18 09:05 initrd.img-4.15.0-76-generic
-rw-r--r--  1 root root 60206115 Apr 18 09:05 initrd.img-4.15.0-91-generic
drwx------  2 root root    12288 Feb 13  2016 lost+found
-rw-r--r--  1 root root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r--  1 root root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r--  1 root root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw-------  1 root root  4068355 Jan 17 05:59 System.map-4.15.0-76-generic
-rw-------  1 root root  8367768 Jan 17 06:27 vmlinuz-4.15.0-76-generic
-rw-------  1 root root  8375960 Feb 28 02:51 vmlinuz-4.15.0-91-generic

My kernel version is 4.15.0-91-generic (based on uname -r).

The output of dpkg --list | grep linux-image is:

c  linux-image-4.15.0-74-generic                               4.15.0-74.84                                     amd64        Signed kernel image generic
ii  linux-image-4.15.0-76-generic                               4.15.0-76.86                                     amd64        Signed kernel image generic
ii  linux-image-4.15.0-91-generic                               4.15.0-91.92                                     amd64        Signed kernel image generic
ic  linux-image-4.4.0-171-generic                               4.4.0-171.200                                    amd64        Signed kernel image generic

This is what happens when I run sudo apt-get upgrade:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  thermald
Use 'sudo apt autoremove' to remove it.
The following packages have been kept back:
  linux-headers-generic
0 upgraded, 0 newly installed, 0 to remove and 1 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] y
Setting up linux-firmware (1.173.17) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-91-generic
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-4.15.0-76-generic
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-69-generic
WARNING: missing /lib/modules/3.19.0-69-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-69-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_BapeFK/lib/modules/3.19.0-69-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_BapeFK/lib/modules/3.19.0-69-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-66-generic
WARNING: missing /lib/modules/3.19.0-66-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-66-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_oFrhwW/lib/modules/3.19.0-66-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_oFrhwW/lib/modules/3.19.0-66-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-65-generic
WARNING: missing /lib/modules/3.19.0-65-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-65-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_cmnh3Q/lib/modules/3.19.0-65-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_cmnh3Q/lib/modules/3.19.0-65-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-59-generic
WARNING: missing /lib/modules/3.19.0-59-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-59-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_kimz35/lib/modules/3.19.0-59-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_kimz35/lib/modules/3.19.0-59-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-58-generic
WARNING: missing /lib/modules/3.19.0-58-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-58-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_yH46Fl/lib/modules/3.19.0-58-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_yH46Fl/lib/modules/3.19.0-58-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-25-generic
WARNING: missing /lib/modules/3.19.0-25-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-25-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_gmb7aZ/lib/modules/3.19.0-25-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_gmb7aZ/lib/modules/3.19.0-25-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: 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.19.0-25-generic with 1.
dpkg: error processing package linux-firmware (--configure):
 installed linux-firmware package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)

Now, the contents of /boot are:

drwxr-xr-x  5 root root     3072 Apr 18 09:14 .
drwxr-xr-x 26 root root     4096 Mar 22 15:43 ..
-rw-r--r--  1 root root   217495 Jan 17 05:59 config-4.15.0-76-generic
-rw-r--r--  1 root root   217457 Feb 28 02:45 config-4.15.0-91-generic
drwxr-xr-x  3 root root     4096 Dec 31  1969 efi
drwxr-xr-x  5 root root     1024 Mar 22 15:50 grub
-rw-r--r--  1 root root 16975438 Apr 18 09:14 initrd.img-3.19.0-58-generic
-rw-r--r--  1 root root 16975489 Apr 18 09:14 initrd.img-3.19.0-59-generic
-rw-r--r--  1 root root 16975434 Apr 18 09:14 initrd.img-3.19.0-65-generic
-rw-r--r--  1 root root 16975144 Apr 18 09:14 initrd.img-3.19.0-66-generic
-rw-r--r--  1 root root 16975428 Apr 18 09:14 initrd.img-3.19.0-69-generic
-rw-r--r--  1 root root 60195966 Apr 18 09:14 initrd.img-4.15.0-76-generic
-rw-r--r--  1 root root 60204841 Apr 18 09:14 initrd.img-4.15.0-91-generic
drwx------  2 root root    12288 Feb 13  2016 lost+found
-rw-r--r--  1 root root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r--  1 root root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r--  1 root root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw-------  1 root root  4068355 Jan 17 05:59 System.map-4.15.0-76-generic
-rw-------  1 root root  8367768 Jan 17 06:27 vmlinuz-4.15.0-76-generic
-rw-------  1 root root  8375960 Feb 28 02:51 vmlinuz-4.15.0-91-generic

It appears that the system is trying to build old initrd files in /boot, and then /boot fills up, and then dpkg fails. How can I fix this?

  • 1
    Have you been perhaps manually deleting files that were originally installed by the package manager? – user535733 Apr 18 '20 at 16:31
  • I removed old images from /boot, per https://askubuntu.com/questions/89710/how-do-i-free-up-more-space-in-boot – Joe Mornin Apr 18 '20 at 20:23
  • None of the high-rated answers in that thread involve manually deleting files, which is the usual cause of the symptoms you are showing. I take it your real problem was that you /boot was full? And this is the result of trying to fix that problem? Exactly which answer did you follow? (each answer has it's own 'share' permalink). Did you follow each step carefully? Or did you skip steps? Were there error messages that you ignored? – user535733 Apr 18 '20 at 20:26
  • Managing old kernels and /boot space has been a chronic problem since I started using Ubuntu many years ago. I'm usually careful to remove unused kernels with apt-get purge linux-image-x.x.x.x-generic. But recently, this has been failing because /boot keeps filling up with outdated initrd.img files whenever i run apt-get upgrade--even for kernels that do not appear in dpkg --list | grep linux-image. I tried to manually delete those initrd.img files from /boot, but that did not solve the problem. – Joe Mornin Apr 21 '20 at 18:46
  • what happens if you add this ppa https://launchpad.net/~gerardpuig/+archive/ubuntu/ppa and install ubuntu-cleaner using apt? – Sam Pan Apr 25 '20 at 13:31
  • What is th Ubuntu verson? The reason is quite clear to ne. But you've did lots of wrong things. – Pilot6 Apr 27 '20 at 16:03

4 Answers4

5
  1. Remove the residue files that tell update-initramfs which kernel is installed

    sudo rm /var/lib/initramfs-tools/3.19*
    
  2. Confirm (there will be no 3.19* images get processed)

    sudo update-initramfs -u -k all
    
  3. Go and fix apt installation

    sudo apt install -f
    

Then you can remove those 3.19* images, permanently.

Note: Step 2 is optional as it is repeated within Step 3 when installing linux-firmware package. I included it to be clear.

user.dz
  • 48,105
4

Carefully read this https://help.ubuntu.com/community/RemoveOldKernels

As per this post you can remove old unused kernel simply with autoremove command in a terminal:

sudo apt-get autoremove --purge  

Note: apt-get autoremove will not remove all automatically installed old kernel providing packages as fallback versions are kept; the list of kept kernels is maintained and automatically updated in the file /etc/apt/apt.conf.d/01autoremove-kernels as a list of matching regular expressions. HENCE I wrote Read above post carefully.

List all the kernels, including the booted one:

dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'

If you want to purge one specific kernel providing package you can do so via the following command in a terminal:

sudo apt-get purge linux-image-4.**.*-**-generic
sudo dpkg --purge linux-headers-4.**.*-* linux-headers-4.**.*-**-generic

Above page also provide on how to "Safely Removing Old Kernels" including initrd.img. Better follow this step by step.

user.dz
  • 48,105
Ajay
  • 678
  • @OP, this is the best way to go about. Trust me, I speak from experience. All others are good, but one little typo and off goes your entire work – kesarling He-Him Apr 27 '20 at 15:37
  • Also, if possible keep the img files upto 3 updates back. It helps when some application gets broken for a particular update :) – kesarling He-Him Apr 27 '20 at 15:39
  • This seems unlikely to work for the OP, since by deleting files manually they have blocked apt ability to complete removals. A file-not-found error during removal will cause dpkg to error...which is what the OP's output seems to show. – user535733 Apr 27 '20 at 15:46
0

Your purges are only getting one of the six packages associated with a kernel, and the leftover pieces are causing problems. For the 3.19 initrd file in /boot, take the numbwer, e.g. 3.19.0-58 and run that through your dpkg --list | fgrep 3.19.0-58. Run your apt-get purge on that list of 3.19 packages. Then take the next one, until all have been fixed.
Do this the next time you want to purge a full kernel -- get the associated packages with dpkg --list | fgrep x.y.z-w then if only packages you want to delete are listed, feed that list to a purge (recall the command in the previous line to produce the list):

dpkg --list |fgrep x.y.z-w
apt-get purge `!!`
ubfan1
  • 17,838
0

One reasonably safe solution for most future readers:

For each no-such-file-or-directory, create a dummy file for apt to remove. Apt doesn't care about the file contents, it just needs to remove the file. So give it a file to remove.

This method can be tedious (you have a LOT) of missing files, but is much safer than the alternative below.


EXAMPLE

Here's one error: /sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory

Files in /etc are owned by root, so create a dummy file using sudo touch /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf

Now there's a file for apt/dpkg to remove, which cures the no-such-file-or-directory error.


A less safe solution is to use dpkg's --force-remove-reinstreq flag. We call that the Nuclear Option - it removes the package entry in the dpkg database without trying to remove any files.

This seems likely to be an effective solution for you (and only you). All future readers should forget they saw it

WARNING Use --force-remove-reinstreq as A LAST RESORT before reinstalling. If you misuse it, you may break your package manager and require a reinstall. This option is for experienced users ONLY. This is strong medicine -- misused, it might kill the patient.

user535733
  • 62,253