How can I remove old kernels/install new ones when /boot is full?

Solution 1:

You cannot use apt-get when your kernel is outdated.

cd /boot
sudo rm *-2.6.35-6.9-generic
sudo rm *-3.16.0-23-generic

use ls to see what is in the folder remove the oldest one or two then

sudo apt-get -f install

Then you cen either apt-get purge as in

sudo apt-get purge linux-image-3.2.0-32-generic linux-image-3.2.0-34-generic

or just continue with rm.

you should also sudo update-grub when you are finsihed

Solution 2:

Apparently, this works:

sudo apt-get autoremove 

According to apt-get man-page:

autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.

3.16.0-39 is the one I tried to install, but failed because /boot was full. 3.16.0-38 is my current version. You can see that -38 was skipped.

server:~$ uname -r
3.16.0-38-generic
server:~$ sudo apt-get autoremove 
[sudo] password for mikeb: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-3.16.0-30 linux-headers-3.16.0-30-generic
  linux-headers-3.16.0-31 linux-headers-3.16.0-31-generic
  linux-headers-3.16.0-33 linux-headers-3.16.0-33-generic
  linux-headers-3.16.0-34 linux-headers-3.16.0-34-generic
  linux-headers-3.16.0-36 linux-headers-3.16.0-36-generic
  linux-headers-3.16.0-39 linux-headers-3.16.0-39-generic
  linux-image-3.16.0-30-generic linux-image-3.16.0-31-generic
  linux-image-3.16.0-33-generic linux-image-3.16.0-34-generic
  linux-image-3.16.0-36-generic linux-image-3.16.0-39-generic
  linux-image-extra-3.16.0-30-generic linux-image-extra-3.16.0-31-generic
  linux-image-extra-3.16.0-33-generic linux-image-extra-3.16.0-34-generic
  linux-image-extra-3.16.0-36-generic linux-image-extra-3.16.0-39-generic
0 upgraded, 0 newly installed, 24 to remove and 0 not upgraded.