3

I work with Ubuntu 13.04 ("64-bit PC (AMD64) desktop image"). On updates/upgrades, I quite often get messages of the type The volume "boot" has only 11 MB disk space. I then uninstall older kernel version to free some space on the boot partition.

Is it possible to automatically remove unused, older kernels when doing sudo apt-get upgrade?

mathlete
  • 1,709

1 Answers1

4

You could add

system ("sudo apt-get remove $(dpkg -l|egrep '^ii  linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)");

to some line in the apt source code for upgrading packages.

Alternatively, just make a script called aptupgrade and paste this in it:

sudo apt-get remove $(dpkg -l|egrep '^ii  linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`); sudo apt-get upgrade

That should leave only 1 old kernel, in case the new kernel borks something.

Eliah Kagan
  • 119,640