Please could you advise which of the following kernels I may remove, and the terminal commands to do so

Asked by jegpad

Hi there, I'm using over 70% of my installation drive and need to free space. I will use Bleachbit (with safer settings than last time when I deleted irrevocably all my Amazon account history and other stuff) but saw in a previous Q&A that old kernels may be deleted. Please could you check out this read out and advise what commands I can run in terminal to free up some space. Many thanks in advance...

jegpad@ubuntu:~$ uname -a; lsb_release -a; dpkg -l | grep linux-image
Linux ubuntu 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
ii linux-image-3.2.0-29-generic 3.2.0-29.46 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-32-generic 3.2.0-32.51 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-33-generic 3.2.0-33.52 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-34-generic 3.2.0-34.53 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-35-generic 3.2.0-35.55 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-36-generic 3.2.0-36.57 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-37-generic 3.2.0-37.58 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-38-generic 3.2.0-38.61 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-39-generic 3.2.0-39.62 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-generic 3.2.0.39.47 Generic Linux kernel image

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bleachbit Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#1

sudo apt-get --purge remove `dpkg -l | awk {'print $2'} | grep -v linux-image-generic | grep -v 3.2.0-29`

In short, you remove any kernels which aren't running and not the 'linux-image-generic' package.

Revision history for this message
jegpad (jane-padley) said :
#2

Thanks HeadVeg, that's done the trick. FYI, found main reason drive was full was a number of undeleted *.iso files. Hmmm.

Revision history for this message
daniel CURTIS (anoda) said :
#3

Hi jegpad. I know, that you've solved this "problem", but I think, that you should/could also remove for example 'linux-headers-3.2.0-36' package and so on, besides normal 'linux-image' package.

,-----[ an example ]
| sudo apt-get --purge remove linux-headers-3.2.0-36
`-----

Cheers.

Revision history for this message
jegpad (jane-padley) said :
#4

Thank you Daniel, that's helped too. Kind of you to inform me.

Revision history for this message
daniel CURTIS (anoda) said :
#5

Hi jegpad. It is just about that, with the removal only of 'linux-image-generic', 'linux-headers' are not removed automatically, but also takes a lot of disk space.