Repository navigation
Kernel Purge
Old kernel images are not automatically removed during apt-get upgrade procedures. This can result in wasted disk space in /boot, and in some cases can end up filling /boot and preventing further updates to the kernel.
A python script purge_old_kernels.py makes the process pailess and automatable.
sudo cp purge_old_kernels.py /usr/local/bin sudo chmod a+x /usr/local/bin/purge_old_kernels.py
Add a cron.weekly task purge-old-kernels:
#!/bin/bash /usr/local/bin/purge_old_kernels.py -q
Removing old kernels is straightforward, as shown in this excerpt from askubuntu.com
Open terminal and check your current kernel:
uname -r
DO NOT REMOVE THIS KERNEL!
Next, type the command below to view / list all installed kernels on your system.
dpkg --list | grep linux-image
Find all the kernels that lower than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.
sudo apt-get purge linux-image-x.x.x.x-generic
Note
You can use bash's brace substitution to refer to a series of kernel versions. For example:
sudo apt-get purge linux-image-2.6.32-4{0..5}-server
Reboot your system.
If you can't run update because the partition is full, then manually removing one of the old images from /boot will generally free up enough space.
This material is based upon work supported by the National Science Foundation under Grant Numbers 083094 and 1430508.
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.