On my laptop, I have several gigs of old kernels lying around, with package names such as linux-image-some_number-generic, linux-image-extra-some_number-generic, linux-headers-some_number, linux-headers-some_number-generic. I want to remove those old kernels, but in a 'safe' way, without inadvertently breaking my system. More specifically, I want to use the package manager aptitude.
I first discovered, from the question 'What does it mean that a package is "set to manually installed?"', that aptitude would not remove these old kernels because they were installed 'manually'. This flag can easily be changed to an 'automatic' flag, which I did. But aptitude is not removing the old kernels regardless.
While trying to figure out why aptitude does not remove these packages, I came across the question 'Can I see why a package is installed?'. Running the command
aptitude why linux-image-some_number-generic
gave me the output
i nautilus Suggests totem | mp3-decoder p vlc-nox Provides mp3-decoder p vlc-nox Depends libcrystalhd3 p libcrystalhd3 Suggests firmware-crystalhd p firmware-crystalhd Suggests linux-image i A linux-image-some_number-generic Provides linux-image
It seems that the packages linux-image-some_number-generic provide 'linux-image', which is suggested by a package I do not even have installed!
It seems that apt-get does not mind removing the old kernels (see also the comments to the accepted answer of the question 'Is aptitude still considered superior to apt-get?'). Running the command
sudo apt-get autoremove
produces the desired result; apt-get asks me if I want to remove all of the packages that I flagged 'automatic'.
My question is the following: How do I make aptitude remove these packages in a way such that aptitude ensures that no dependencies are broken?
EDIT: The following unanswered question seems to be related: Aptitude conflicts with apt-get. EDIT: The following question may also be related: aptitude ugrade does not change my kernel. EDIT: I found a question on unix stackexchange which may also be related: Aptitude doesn't remove automatically installed packages.