Distro-provided mechanism to clean up old kernels

Kees Cook kees at ubuntu.com
Thu Feb 16 20:31:12 UTC 2012

On Thu, Feb 16, 2012 at 02:21:18PM -0500, Barry Warsaw wrote:
> On Feb 16, 2012, at 10:11 AM, Dustin Kirkland wrote:
> >I asked about this in IRC yesterday, and Colin Watson pointed me to
> >the computer-janitor utility, which is intended to handle this.
> >Seconds later, Barry Warsaw told me that computer-janitor should die
> >:-)
> c-j needs attention, but I'm not particularly motivated to give it what it
> needs.  There's basic housekeeping, such as that the code for c-j is sprinkled
> between the update-manager and the computer-janitor packages, and even more
> important problems such LP: #458872.  What's demotivating though is that in
> all the discussions we've had about the tool, most people think it's just not
> user-friendly enough given today's emphasis on software-center.

FWIW, this is the highly advanced system I use for my auto-updated VMs. It
keeps the latest 2 kernels:

OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | \
	awk '{print "linux-image-" $0}')
if [ -n "$OLD" ]; then
    apt-get -qy remove --purge $OLD

Be warned, of course, that if you don't reboot often, you can end up
removing the kernel you're running. :P


Kees Cook

More information about the ubuntu-server mailing list