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?

  • If you're getting the volume "boot" has only 11 MB disk space message and don't know what the OP is talking about, this answer explains a non-automatic solution: http://askubuntu.com/questions/218783/the-volume-boot-has-only-0-bytes-disk-space-remaining – Kevin Oct 03 '13 at 22:32

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
  • 117,780
Yet Another User
  • 2,671
  • 3
  • 23
  • 37