Ubuntu – Cannot delete old kernels

aptdeletekernel

I ran the command:

dpkg -l | grep linux-image-

and got this list

rc linux-image-3.13.0-51-generic 3.13.0-51.84
rc linux-image-3.13.0-52-generic 3.13.0-52.86 rc linux-image-3.13.0-53-generic 3.13.0-53.89
rc linux-image-3.13.0-54-generic 3.13.0-54.91
rc linux-image-3.13.0-55-generic 3.13.0-55.94 rc linux-image-3.13.0-57-generic 3.13.0-57.95 rc linux-image-3.13.0-58-generic 3.13.0-58.97
rc linux-image-3.13.0-59-generic 3.13.0-59.98
rc linux-image-3.13.0-61-generic 3.13.0-61.100
ii linux-image-3.13.0-62-generic 3.13.0-62.102
rc linux-image-extra-3.13.0-30-generic 3.13.0-30.55 rc linux-image-extra-3.13.0-46-generic 3.13.0-46.79
rc linux-image-extra-3.13.0-49-generic 3.13.0-49.83
rc linux-image-extra-3.13.0-51-generic 3.13.0-51.84
rc linux-image-extra-3.13.0-52-generic 3.13.0-52.86 rc linux-image-extra-3.13.0-53-generic 3.13.0-53.89
rc linux-image-extra-3.13.0-54-generic 3.13.0-54.91
rc linux-image-extra-3.13.0-55-generic 3.13.0-55.94
rc linux-image-extra-3.13.0-57-generic 3.13.0-57.95
rc linux-image-extra-3.13.0-58-generic 3.13.0-58.97
rc linux-image-extra-3.13.0-59-generic 3.13.0-59.98
rc linux-image-extra-3.13.0-61-generic 3.13.0-61.100
ii linux-image-extra-3.13.0-62-generic 3.13.0-62.102
ii linux-image-generic 3.13.0.62.69

So I then ran:

sudo apt-get autoremove linux-image-3.13.0-51-generic 

and got this:

Reading package lists... Done Building dependency tree
Reading state information... Done Package 'linux-image-3.13.0-51-generic' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

So do I or do I not have unused old kernels on my system and how should I remove them??

Best Answer

In the first two columns of your dpkg -l generated list of kernels you will find information on the package as follows:

  1. Column (desired action):

    u = Unknown
    i = Install
    h = Hold
    r = Remove
    p = Purge
    
  2. Column (package status):

    n = Not-installed
    c = Config-files
    H = Half-installed
    U = Unpacked
    F = Half-configured
    W = Triggers-awaiting
    t = Triggers-pending
    i = Installed
    

For your first example

rc linux-image-3.13.0-51-generic 3.13.0-51.84

it will hence tell us that the packages was removed (r) but the configuration files are still there (c). Only those kernels marked ii are actually installed on your system. Autoremove will only remove obsolete kernels but will leave the configuration files.

To also remove these we'd have to purge an installed package (sudo apt-get purge <package>) but leaving them does no harm and they do not need much hard drive space.

Related Question