clean /boot - remove old kernels

22/11/2020

see current kernel version

uname -r
5.4.0-52-generic

see all kernels installed

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'

Check that we have the latest version. if needed, reboot the machine and recheck step 1.

delete each one except the current. run this repeatedly

# start with linux-image-*-generic
apt-get purge linux-image-4.15.0-122-generic

# only if no disk space left : dpkg --remove linux-image-4.15.0-122-generic

# after we reclean
apt-get autoremove --purge

if it fails you can backup /boot & rm images & regenerate images

cp -r /boot/ initramfs/
rm -rf /boot/initrd.img*
update-initramfs -c -k all
apt-get upgrade

see /boot

ls /boot/initrd.img-*

pour faire un clean parfait supprimer :

rm /boot/config-xxxx-generic
rm /boot/System.map-xxxx-generic
rm /boot/vmlinuz-xxxx-generic

Raccourcis