Clean /Boot Kernel Images
There will be time when the /boot
partition is bloated with kernel images set. Since the kernel is managed by packages, one should use the package manager to safely remove them instead of manual deletion.
Scan The /Boot Packages
The first thing to do is to scan the /boot
packages. This can gives you a list of packages responsible for generating those kernel images. You can do that using root account by:
$ dpkg --list 'linux-image*'
This gives you a list of installed kernel images like the following:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Descr...
+++-========================================-================-============-=====...
ii linux-image-4.4.11-0-amd64 4.4.11-1 amd64 Linux...
un linux-image-4.4.11-0-amd64-unsigned <none> <none> (no d...
ii linux-image-5.5.0-0.bpo.2-amd64 5.5.17-1~bpo10+1 amd64 Linux...
un linux-image-5.5.0-0.bpo.2-amd64-unsigned <none> <none> (no d...
ii linux-image-amd64 5.5.17-1~bpo10+1 amd64 Linux...
You must identify the one you plan to use and the one that you wish to get rid of.
Remove via Purging
To remove the unused images, simply purge the packages. Assuming that we want to remove the version 4.4.0 above, we just uninstall its corresponding package:
$ apt purge linux-image-4.4.11-0-amd64
Once done, you can scan again to check its deletion.
NOTE: if the kernel image version is governed by linux-image-amd64 (they share the same "Version" number), then you need to remove the generic term first. However, in practice, this is unlikely to happen.
That's all for cleaning up /boot
partition safely.