How to remove old unused kernels

Asked by steve hussey

Running Gateway P4 1.5 GHz, 512 MB RAM, 10.04.2, all updates applied.

Quite a few listed files in Computer Janitor when run, including linux headers 2.26.32-24, linux 2.26.32-24 generic.

Safe to remove all?

mchain

Question information

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

Can you give the output of:

dpkg -l | grep linux-image-2; uname -a

You can also run:

sudo apt-get --purge autoremove

Usually the janitor is ok

Revision history for this message
marcus aurelius (adbiz) said :
#2

it depends on whether you have programs you installed outside the software center and synaptic package manager. if you do, janitor will delete them and you'll be scratching your head and swearing. it DID tell you to verify everything before deleting. anyways, I find bleachbit, which is available in the software center, to be more idiot proof.

Revision history for this message
steve hussey (srhussey1) said :
#3

actionparsnip,

How do I get an output and copy it? Bear with me here, as I try not to run terminal any more often than required.

marcus aurelius,

No programs are installed from outside the software center or synaptic manager. I believe it is safer that way, as for example, Clamtk does not have the latest anti-virus engine because Canonical provides native support for it within Update Manager, and those updates are always behind what is out there on the Internet. Another example would be Firefox 4.

BTW, as I am busy ATM, I will be getting back to you around ten o'clock or so.

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

Yes its a terminal command, We can help you free more space

Revision history for this message
steve hussey (srhussey1) said :
#5

actionparsnip,

Don't know when this will reach you, but if you answer tomorrow, that will be OK.

Here is the output of the terminal command above:

To wit -- dpkg -l | grep linux-image-2; uname -a, as in

babyg@babyg-desktop:~$ dpkg -l | grep linux-image-2; uname -a
ii linux-image-2.6.32-24-generic 2.6.32-24.43 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-25-generic 2.6.32-25.45 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-26-generic 2.6.32-26.48 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-27-generic 2.6.32-27.49 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-28-generic 2.6.32-28.55 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-29-generic 2.6.32-29.58 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-30-generic 2.6.32-30.59 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-31-generic 2.6.32-31.61 Linux kernel image for version 2.6.32 on x86
Linux babyg-desktop 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:24:35 UTC 2011 i686 GNU/Linux
babyg@babyg-desktop:~$

I am not short on free space. Deleting files in Computer Janitor is not needed for that. I just needed to ensure that, if needed, I could safely delete these files, including the ones listed for linux 2.6.32-24. 32-24, btw, is the only such file listed that involves the kernel, and is the first one installed with the introduction of 10.04.0.

I am seeing several entries in grub, (see above). Are all of these entries needed? Again, I am not seeking to regain lost space on my hdd, just thinking of removing unneeded files. Should I?

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#6

ok then if you run:

sudo apt-get --purge remove linux-image-2.6.32-24-generic linux-image-2.6.32-25-generic linux-image-2.6.32-26-generic 2.6.32-26.48 linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-get --purge autoremove

You will now have a LOT more space and only ONE kernel

Revision history for this message
steve hussey (srhussey1) said :
#7

actionparsnip,

Yeah, that is really why I was looking at Computer Janitor.

As it is late in the night, I will run this command in the morning.

Will let you know how it went.

Thanks.

mchain

Revision history for this message
steve hussey (srhussey1) said :
#8

actionparsnip,

I ran the terminal sudo command, and nothing happened.

I copied and pasted the above to ensure there were no typos or errors.

This is what I copied:

sudo apt-get --purge remove linux-image-2.6.32-24-generic linux-
image-2.6.32-25-generic linux-image-2.6.32-26-generic 2.6.32-26.48
linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic
linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-
get --purge autoremove

The only thing terminal said it was going to remove was linux-image2.6.32-generic.

I then checked grub2 and that entry was still there. Should I run sudo grub-update?

I got to thinking, and this is what I came up with:

sudo apt-get --purge remove linux-image-2.6.32-24-generic 2.6.32-24.43
linux-image-2.6.32-25-generic 2.6.32-25.45 linux-image-2.6.32-26-generic
2.6.32-26.48 linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.
32-28-generic 2.6.32-28.55 linux-image-2.6.32-29-generic 2.6.32-29.58
linux-image-2.6.32-30-generic 2.6.32-30.59; sudo apt-get --purge autoremove

Is this what you meant?

How much space are we speaking about, exactly?

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#9

Its all one command, copy it as on e big blok of command and paste it into a terminal. It will remove all the kernels you don't want

Revision history for this message
steve hussey (srhussey1) said :
#10

actionparsnip,

Sorry, ONE error in above: terminal said it was going to remove was linux-image 2.6.32.24-generic

Oops!

mchain

Revision history for this message
steve hussey (srhussey1) said :
#11

actionparsnip,

Which one do I use, though?

Your's did not seem to work.

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#12

sudo apt-get --purge remove linux-image-2.6.32-25-generic linux-image-2.6.32-26-generic 2.6.32-26.48 linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-get --purge autoremove

Revision history for this message
steve hussey (srhussey1) said :
#13

actionparsnip,

I made sure to only use your commands.

Here is the output from terminal:

babyg@babyg-desktop:~$ sudo apt-get --purge remove linux-image-2.6.32-25-generic linux-image-2.6.32-26-generic 2.6.32-26.48 linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-get --purge autoremove

Reading package lists... Done

Building dependency tree

Reading state information... Done

E: Couldn't find package 2.6.32-26.48

Reading package lists... Done

Building dependency tree

Reading state information... Done

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

babyg@babyg-desktop:~$

Did not seem to work.

What else could I do?

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#14

sudo apt-get --purge remove linux-image-2.6.32-25-generic linux-image-2.6.32-26-generic linux-image-2.6.32-26-generic linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-get --purge autoremove

Revision history for this message
steve hussey (srhussey1) said :
#15

actionparsnip,

Terminal (new version) output again:

babyg@babyg-desktop:~$ sudo apt-get --purge remove linux-image-2.6.32-25-generic linux-image-2.6.32-26-generic linux-image-2.6.32-26-generic linux-image-2.6.32-27-generic 2.6.32-27.49 linux-image-2.6.32-28-generic linux-image-2.6.32-29-generic linux-image-2.6.32-30-generic; sudo apt-get --purge autoremove

[sudo] password for babyg:

Reading package lists... Done

Building dependency tree

Reading state information... Done

E: Couldn't find package 2.6.32-27.49

Reading package lists... Done

Building dependency tree

Reading state information... Done

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

babyg@babyg-desktop:~$

Same result!

mchain

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#16

ok lets do it this way:

sudo apt-get -y --purge remove linux-image-2.6.32-30-generic
sudo apt-get -y --purge remove linux-image-2.6.32-29-generic
sudo apt-get -y --purge remove linux-image-2.6.32-28-generic
sudo apt-get -y --purge remove linux-image-2.6.32-27-generic
sudo apt-get -y --purge remove linux-image-2.6.32-26-generic
sudo apt-get -y --purge remove linux-image-2.6.32-25-generic
sudo apt-get -y --purge remove linux-image-2.6.32-24-generic
sudo apt-get --purge autoremove

Should be good, did you not read the command given so you could tidy it up yourself, I'd say what was trying to be ran is pretty obvious. I have broken it up into indicidual commands so is very easy

Revision history for this message
steve hussey (srhussey1) said :
#17

actionparsnip,

I ran the above, and did get a different result.

linux-image-2.6.32-30-generic was removed.

I copied and pasted all above as one piece and that was the only one removed.

I noticed that the files are listed in the order posted in grub2.

Terminal said the intrinic-vimux?.old file was defective, so it removed both instances, (I did not copy and paste output as information in terminal should not be posted on the Internet) and typed exit when batch file executed. It did say I might have to re-run grub. Grub seems to work at the moment.

As I have a dual-boot system, I did not want grub2 to lose that information as well.

Sorry about that. I did not know I was supposed to clean up the commands myself. I do not normally run terminal as one can get a real pickle if one does not know what they are doing.

Thanks for your help.

At least one of them is gone. I regained 99 MB of space with this removal.

What now?

mchain

I am sure many of the clients you have come to you for that very reason.

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#18

Cool, now keep running the others and the kernels you don't want will be removed.

Revision history for this message
steve hussey (srhussey1) said :
#19

actionparsnip,

Wow! Gotcha! What a neat thing!

Now I am going to boot my linux box and do some cleaning!

Let you know v soon.

mchain

Revision history for this message
steve hussey (srhussey1) said :
#20

actionparsnip,

It is done.

Grub2 looks much nicer.

Thanks.

mchain

Revision history for this message
steve hussey (srhussey1) said :
#21

Thanks actionparsnip, that solved my question.