I have been going through various questions about how to clean up old Linux kernels. They all seem to have different answers and they are old, so someone is bound to say the question is too old and start a new post, so here it is:
I want to do all the following:
- Remove old Linux kernels manually in terminal.
- Remove all configuration files
- Remove all header files
- Remove unnecessary inodes?
- Explain why dpkg -l | grep linux-image does not return the same results as what I see in my grub2 listing during boot
- Explain rc vs ii in the dpkg -l | grep linux-image listing
- Explain the discrepancy between entries in /usr/src directory (or wherever these files are found in other Ubuntu versions) and the above two methods of determining excess kernel versions.
- What are the ramifications of a complete cleanup of older kernels. Do I need to worry about dependencies? How do I know if any apps on my computer are dependent on the configurations files of older kernels.
What I don't want:
- Links to other answers that you have not personally tested or do not address ALL the issues involved in a complete cleanup.
- Any answer you have not personally tested.
- Scripts that attempt to automatically clean everything at once. I just want to do this manually until I fully understand everything that is going on.
Let's please get a comprehensive solution to the kernel buildup problem. I am currently playing with an older version of Ubuntu (10.04) before I upgrade, but I have had the same problem with Ubuntu 12.04. If the solution is different for different versions, please state the version you used to test your solution.
This correctly returns the kernel version I am currently using.
Things that don't work:
sudo apt-get autoremove sudo apt-get clean sudo apt-get autoremove linux-image-x.x.xx-xx-generic
What I thought should work, but did not:
sudo apt-get purge linux-image-x.x.xx-xx-generic
This worked to diminish the list generated by
dpkg -l | grep linux-image:
sudo dpkg --purge linux-image-x.x.xx-xx-generic
Also here is a head start on the
ii means 'It should be installed and it is installed' whereas
rc means 'It's removed/uninstalled but it's configuration files are still there'.
I think this addresses the issue between the discrepancy between the terminal listing and the grub2 menu at bootup. As I recall, the
ii listings match the grub2 listing. The question here is how did the
ii entries get there in the first place?