Removing and/or Cleaning Up Old Kernels
This post shows how to remove (clean up) old kernels. Old kernels (to me) are defined as kernels that are installed on your system but no longer needed/used.
You can use a package manager (such as synaptic) to remove old kernels, simply search for linux-image or linux-headers that are installed and remove them. Also of importance is to note that you should remove old kernels and headers together as one is not useful without the other in most circumstances.
The following steps show how to do this via command line. The first step is to get a list of all 'headers' that are installed:
dpkg -l linux-headers-\* | grep ii
This should produce result like the following:
ii linux-headers-2.6.38-10 2.6.38-10.46 Header files related to Linux kernel version 2.6.38
ii linux-headers-2.6.38-10-generic 2.6.38-10.46 Linux kernel headers for version 2.6.38 on x86/x86_64
ii linux-headers-2.6.38-11 2.6.38-11.48 Header files related to Linux kernel version 2.6.38
ii linux-headers-2.6.38-11-generic 2.6.38-11.48 Linux kernel headers for version 2.6.38 on x86/x86_64
ii linux-headers-generic 184.108.40.206.26 Generic Linux kernel headers
ii linux-headers-2.6.38-8 2.6.38-8.46 Header files related to Linux kernel version 2.6.38
ii linux-headers-2.6.38-8-generic 2.6.38-8.46 Linux kernel headers for version 2.6.38 on x86/x86_64
You will obviously want to leave your current headers (you can find this with the 'uname -a' command), I also like to leave the previous version just in case there are some issues and I need to boot with it. This means you would remove the 'linux-headers-2.6.38-8' and 'linux-headers-2.6.38-8-generic' header files, you can do so with the following command:
sudo apt-get remove linux-headers-2.6.38-8 linux-headers-2.6.38-8-generic
Removing Kernel Images
Next, you should remove the corresponding kernels as they are no longer needed. You can find the kernel names with the following command:
dpkg -l linux-image-\* | grep ii
The results should be similar to those listed in the headers output. Remove old kernels with the following command:
sudo apt-get remove linux-image-2.6.38-8-generic
Finally, cleanup your environment by removing any packages the kernel(s) you just removed my have referenced with the 'autoremove' feature in apt with the following command:
sudo apt-get autoremove
I also like to do a 'sudo apt-get autoclean' at this time as well.