update-initramfs: failed for /boot/initrd.img-4.15.0-112-generic with 1

All we need is an easy explanation of the problem, so here it is.


when i run dist-upgrade i ran into the problem with below detail

1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LC_TERMINAL = "iTerm2",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-112-generic
W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast
Error 24 : Write error : cannot write compressed block
E: mkinitramfs failure lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-4.15.0-112-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

can any one help this problem?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

The real error message tucked away in all that output is Write error : cannot write compressed block which, by an overwhelming margin, is found to be the result of insufficient free space available for the creation of the new initramfs image. Remember, you need sufficient space for the uncompressed image in your /boot folder, which is then replaced by the compressed version, though since you’re using the lz4 compression algorithm, there’s probably not a major size difference (I’d guess < 20%, myself).

I see a couple different ways to ameliorate your issue, beyond just going through the /boot directory with a fine-toothed comb and looking for cruft you can safely relocate/delete, which should be your first approach.

  1. In the event that doesn’t result in enough additional free space to permit the generation of the new initrd file, then it should be seen if you’re carrying any old kernel packages on your system that can be purged, taking their initrd files with them. Fire up a terminal emulator and examine the output of dpkg --list | grep '^linux-', looking for any with a version string that doesn’t match the kernel you’re currently booting with, which can be verified quickly from the output of uname -r. If you have some that meet that criteria and feel comfortable jettisoning them for the sake of successfully completing your package update, just supply those package names as arguments after sudo dpkg --purge.
  2. If you only have packages installed for the kernel version you’re actively running, you may need to resort to relocating your current initrd file out of the /boot directory and then seeing if you can finish the package update, which will of course furnish you with a shiny, new initramfs and then you can safely delete the old one that you relocated. That would look something like this, assuming that the working directory of the shell instance being used is on a different filesystem than /boot (plain English: make sure to cd to some folder on a different partition first, or if that’s not possible and your /tmp folder is a mounted tmpfs partition, then cd /tmp), then do:
# This'll provide a useful report of the files that get moved incase the package
# update fails and you need to put them back where you found them
sudo mv -iv /boot/*initrd "$(pwd)"

# Now time to do a little housekeeping on the package manager and see if
# the update will complete successfully
sudo apt autoremove
sudo apt autoclean
sudo apt --fix-broken install
sudo dpkg --configure -a

If you still encounter the same error and you’re sure the free space issue has been resolved, then the conclusion must be that something is really messed up with the initramfs-tools package as it currently exists on your system, so try and return it to a pristine condition with this command sequence:

sudo apt remove initramfs-tools
sudo apt clean
sudo apt -y install initramfs-tools

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

Leave a Reply