Write error : cannot write compressed block
I have Ubuntu 20.04 root on zfs installed using the instruction on the OpenZFS project.
I was wondering if someone could help me get past this:
root@ubuntuzfs:~# apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 33 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.136ubuntu6.3) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.3) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-48-generic
Error 24 : Write error : cannot write compressed block
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.4.0-48-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:
initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
From what I can understand this problem is caused by insufficient room on my root partition.
Here is some information that may be relevant.
root@ubuntuzfs:~# zfs list -o space -r bpool
NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD
bpool 48.6M 319M 0B 96K 0B 319M
bpool/BOOT 48.6M 317M 0B 96K 0B 317M
bpool/BOOT/ubuntu 48.6M 317M 160K 317M 0B 0B
root@ubuntuzfs:/boot# du -bsh *
233K config-5.4.0-45-generic
233K config-5.4.0-47-generic
233K config-5.4.0-48-generic
7.8M efi
7.6M grub
27 initrd.img
93M initrd.img-5.4.0-45-generic
93M initrd.img-5.4.0-47-generic
93M initrd.img-5.4.0-48-generic
27 initrd.img.old
179K memtest86+.bin
181K memtest86+.elf
181K memtest86+_multiboot.bin
4.6M System.map-5.4.0-45-generic
4.6M System.map-5.4.0-47-generic
4.6M System.map-5.4.0-48-generic
24 vmlinuz
12M vmlinuz-5.4.0-45-generic
12M vmlinuz-5.4.0-47-generic
12M vmlinuz-5.4.0-48-generic
24 vmlinuz.old
Can anyone suggest files from this list I could delete to create some room?
Solution 1:
After looking into this more I discovered that during the boot process the kernel has to mount the root partition. The modules needed to enable this are not compiled into the kernel but are located in the “/lib/modules/” directory which is on the root partition. The kernel cannot access the necessary modules for mounting the root partition which are located on the root partition without first mounting the root partition so its a catch 22. The initrd image exists to solve this problem. The initrd image contains the modules required for mounting the root partition. The initrd image resides on the same partition as the kernel image. During the boot process the kernel loads the initrd image into memory and is then able to access the required modules to mount the root partition.
As can be seen from my disk usage over half the space on the boot partition is taken up by three initrd images. Only one is required so I was able to create a lot of extra space by deleting the two older initrd images. I could also have deleted all the initrd images and made a new one with
sudo update-initramfs -c -k $(uname -r)
Solution 2:
I ran into this problem when trying to run update-initramfs
manually, but you will encounter this like OP above if you're trying up update packages and the updater calls update-initramfs
due to a kernel upgrade. You get the same error if there no longer any space on the /boot
partition and you have a dedicated partition for /boot
that is distinct from the root partition (/
) and/or /home
partition. For example, if you have a LUKS encrypted root, home and swap partition and run out of space on the separate non-encrypted boot parition.
You can fix it by removing a few old kernel entries, or by deleting old initrd.img-<VERSION>-generic
files in the \boot
partition and running update-grub
. You should then be able to update the kernel properly.