There are several good answers here regarding how to fix problems caused by a full /boot partition. What I'd like to know is if there is any best practices for proactively managing this issue before it becomes a problem.
I routinely go many weeks and sometimes several months between reboots. The need to apply patches frequently is rarely an issue with Linux like it is with MS. If I didn't mind rebooting every few days I'd just run Windows.
I am running a small farm of Ubuntu 16.04 LTS machines. I added the following to one of them as a test:
sudo crontab -e
1 9 * * 2 apt -y autoremove --purge >> /dev/null
This runs a purge once a week which should be more than frequent enough. This does work although I did a manual purge before creating the cron job so there may be issues when there is actually something in there to purge. Like, will this command run to successful completion unattended in all situations? Any unforeseen unintended consequences of using this approach? Is there a better OOB management scheme? For supportability reasons I would prefer to avoid using custom scripts.
Many thanks in advance.
https://help.ubuntu.com/community/RemoveOldKernels specifically says that the following does NOT purge old kernels:
File: /etc/apt/apt.conf.d/50unattended-upgrades
Set: Unattended-Upgrade::Remove-Unused-Dependencies "true";
You could use an adaptation of this one-liner I found somewhere on this site:
sudo dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'
uname -r
'/q;p' | xargs sudo apt-get -y purgeIt will remove and purge all kernels except the one you're currently using.