What to do about update-initramfs errors during kernel upgrade?
The reason might be that you are running out of free disk space (maybe because you created a too small /boot
partition on your hard disk) and you are having too many old kernels installed.
The most proper way to clean up old kernels completely, is to remove them with this command :
sudo apt purge linux-headers-* linux-headers-*-generic linux-image-*-generic linux-image-extra-*-generic linux-signed-image-*-generic
To check which kernel versions currently are installed on the system ... execute this command :
sudo dpkg --get-selections | grep linux
Replace * with the kernel versions (for instance : 4.4.0-36
) from the output of the command.
Example - this is the command to completely remove all traces from kernel version 4.4.0-36
:
sudo apt purge linux-headers-4.4.0-36 linux-headers-4.4.0-36-generic linux-image-4.4.0-36-generic linux-image-extra-4.4.0-36-generic linux-signed-image-4.4.0-36-generic
Alternatively you can use byobu
from Dustin Kirkland (Canonical) to get rid of the older kernels :
sudo apt install byobu
sudo purge-old-kernels
This will remove all older kernels, but leaves the current (of course) and the one before installed.
Your computer is out of disk space.
Free up some in /boot
.
Then rerun the command.
Update: In chat we found that the /boot
partition was full. This is where disk space should be freed.
Update 2: Doing ls /boot
should show some vmlinuz-X.XX.XX
files. Do apt-get purge linux-image-X.XX.XX-generic
for each one. Just keep the latest one in case the one you install doesn't work. (Thanks to edwinksl for requesting information on how to do this).
Hopefully this well help someone else.
I was trying to manually install a newer kernel version some months ago, with similar results to OP.
Even though /boot
is only 30% full I was getting the same out of disk space error when running apt-get autoremove
, it would try to build the initramfs for the new kernel every time and fail.
Based on this AskUbuntu question I moved the offending Kernel file from /var/lib/initramfs-tools
and was able to get apt-get running again without errors.