For years Ubuntu has had the ability to automatically patch the system via crontab, however as kernel updates are applied old revisions are never purged (in the event there is an issue). However, if you have a smaller drive for your install say as a Virtual Machine the /boot volume can be sized pretty small. Eventually you’ll start to see upon login a message warning you the partition is over 80% full, in this case we need to go back and purge some old kernels.
Lets check to see how bad it currently is?
df -h /boot
Filesystem Size Used Avail Use% Mounted on /dev/sda1 228M 190M 38M 83% /boot
So lets obtain our currently running build information
sudo uname -r
Now, lets take a look at what is currently installed.
sudo dpkg -l linux-image-\* | grep ^ii
Which returned for me returned
ii linux-image-3.5.0-23-generic 3.5.0-23.35 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-36-generic 3.5.0-36.57 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-37-generic 3.5.0-37.58 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-39-generic 3.5.0-39.60 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-40-generic 3.5.0-40.62 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-44-generic 3.5.0-44.67 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-45-generic 3.5.0-45.68 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-46-generic 3.5.0-46.70 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-3.5.0-47-generic 3.5.0-47.71 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-23-generic 3.5.0-23.35 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-36-generic 3.5.0-36.57 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-37-generic 3.5.0-37.58 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-39-generic 3.5.0-39.60 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-40-generic 3.5.0-40.62 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-44-generic 3.5.0-44.67 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-45-generic 3.5.0-45.68 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-46-generic 3.5.0-46.70 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-extra-3.5.0-47-generic 3.5.0-47.71 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP ii linux-image-generic 3.5.0.47.63 amd64 Generic Linux kernel image
At this point everything has been stable for a few weeks, so I will purge anything below 3.5.0-47.
sudo apt-get purge linux-image linux-image-3.5.0-23 linux-image-3.5.0-36 linux-image-3.5.0-37 linux-image-3.5.0-39 linux-image-3.5.0-40 linux-image-3.5.0-44 linux-image-3.5.0-45 linux-image-3.5.0-46
After everything was removed, lets check again to see where we sit.
df -h /boot
Filesystem Size Used Avail Use% Mounted on /dev/sda1 228M 29M 188M 14% /boot
In the end we ended up clearing up 69% of the /boot partition.