Note: Only in cases where cleanup cannot be done with apt due to 100% full/boot
Get a list of kernel images and determine which will be removed. This command will display the installed kernels, except for the currently running kernel
dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`
linux-image-4.15.0-46-generic
linux-image-4.15.0-50-generic
linux-image-4.15.0-51-generic
linux-image-4.15.0-52-generic
linux-image-4.15.0-54-generic
Linux-image-4.15.0-55-generic
First, get the list of currently running Linux kernels and run:
v="$(uname -r | awk -F '-virtual' '{ print $1}')"
4.15.0-47-generic
Use brace expansion to keep your boot clear, you can write a command to delete all files in /boot that are not related to the kernel. Remember to exclude the current and two latest kernel images. In the example above, it is
rm -rf /boot/*-4.15.0-{46,50,51,52,54,55}-*
Or move these files in another directory.
mv /boot/*-4.15.0-{46,50,51,52,54,55}-* /media/backup/boot/
Cleanup
apt-get -f install
apt-get autoremove
update-grub
apt-get update
Comments
Post a Comment