Ubuntu – Why doesn’t Ubuntu remove old kernels automatically?

kernel

I wonder why Ubuntu won't remove the old kernels automatically.

Surely nothing is perfect and things can go wrong, so in case a update doesn't work, having a backup kernel maybe great. But it would also suffice to just keep the latest kernel and the one before the latest and delete all the older ones.

Is there a reason why Ubuntu won't do this automatically?.

Best Answer

  • Is there a reason why Ubuntu wont do this automatically?

    I can see only 1 reason: it does not work flawlessly; there is no clean way to currently decide what the definition of "old kernels" is. "old" does not mean "unused" nor does it mean "unwanted". And any mistake in this will kill a users' machine.

    So up to now the manual method is preferred since this puts the power of removing into the users' hands.


    Resources for this conclusion:

    Ubuntu WIKI: Proposal for removing old kernels

    Last-good-boot is implemented fully in Intrepid/8.10 final, however it has been disabled because it was not considered stable enough. The setting is a single line in the file /etc/default/kernel-helper-rc.


    Launchpad: Should aptitude provide a way to remove old kernel versions ?

    apt-get has an autoremove feature that uninstalls all packages that are not needed as dependencies and have not been installed manually. Since Ubuntu 14.04 all obsolete kernels and headers should automatically be flagged as no more needed, and thus can be purged with the apt-get autoremove command. (There are reports that this does not yet fully work). I am not aware of a feature in aptitude that is similar to apt-get's autoremove.


    Ubuntu-devel: Distro-provided mechanism to clean up old kernels

    While agreeing that it would be quite helpful and seems appropriate to have the cleanup automatic, there is a slight potential pitfall (or two). There are various flavours of kernels and people may or may not deliberately have those installed in parallel. Also various releases had sometimes a changing set of depending packages. For a while this should be only linux-backports-modules (there had been linux-ubuntu-modules and linux-restricted-modules). Though this is not so much of a problem. From a pattern matching point of view the generic-pae kernels are a bit of a pain as they tend to ruin the "use the last part of a split by "-" for the flavor". But anyway, I think the main issue is the various flavours, so a cleanup that is automatic should retain the last three of each, even though this may tend to leave more kernels around.