Pontus Öwre

Dedicated and diverse software engineer with 15+ years professional experience. Passionate about software security, test driven development and DevOps with interest in getting things done.

Kernel Panic and Overflowing Boot Partition

Posted

Recently I experienced a kernel panic on my Linux system. A kernel panic is a critical error that occurs when the Linux kernel detects an unrecoverable error. When a kernel panic occurs, the system will stop responding or fail to startup.

The cause of the kernel panic can vary, but in my case, it was caused by a full boot partition. The boot partition is where the kernel and initramfs are stored. If the boot partition is full, the system cannot boot properly, and you will see a kernel panic. This can happen when updating the kernel and initramfs files, as they are written to the boot partition.

The following command can be used to list the current kernel version and all installed kernel versions:

uname -r
dpkg --list 'linux-image*' | grep ^ii

The following commands can be used to remove old kernel versions:

sudo apt-get remove linux-image-5.4.0-{91,122,124,135}
sudo apt autoremove
sudo update-grub

Example error message when updating the kernel and initramfs files:

sudo update-initramfs -u -k 5.13.0-40-generic
update-initramfs: Generating /boot/initrd.img-5.13.0-40-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgkubuntu-swap_1)
I: Set the RESUME variable to override this.
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.13.0-40-generic with 1.

The error message Error 24 : Write error : cannot write compressed block indicates that there was an error writing the compressed block to the initramfs file. This can happen if the boot partition is full or if there are other issues with the filesystem.