out of date kernels still taking up hd room

Asked by larrycraig

9.04 alpha2 deletes old kernels automatically on update, but 8.10 doesn't. Can I manually delete these unwanted kernels. I need the room on hd. I'm dual booted with Vista and haven't a large hd. The install was done with Wubi and works beautifully, but I've upgraded the kernel a couple of times with update and the unused portion has gone from 5.5 gi to 1.9gi. it's too close for comfort.

Question information

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

see if this command will free up some space for you:

sudo apt-get clean

then you can go to System->Administration->Synaptic Package Manager

click on the search button and search for "linux-header" in the name field.

Now you can remove the unused kernels and it will also remove them from the grub menu as well. be sure to leave at least one or you wont be able to boot! personally i like to use the latest kernel and leave the previous one for backup.

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#2

Hi,

I created a Linux bash script called removekernel

Here are the contents of the removekernel script:

#!/bin/ksh

if [[ $1 == "" ]]; then
echo "No argument added after removekernel command"
echo "Please enter kernelversion to remove from your pc (for example: 2.6.24-16) "
read KERNELVERSION

echo "Removing kernelversion $KERNELVERSION"
apt-cache search $KERNELVERSION|cut -d" " -f1|xargs sudo apt-get remove -y

else
echo "Removing kernelversion $1"
apt-cache search $1|cut -d" " -f1|xargs sudo apt-get remove -y
fi

The script above will allow you to remove previous kernel versions with ease.

After making the script removekernel executable, you can use it like this in the Terminal:

removekernel 2.6.24-19

to delete the 2.6.24-19 kernel.

Watch out though: if you use the following command and you do not have any 2.6.27 kernels installed, then you wipe out ALL available Linux kernels:

removekernel 2.6.24

is VERY dangerous :-)

Regards,

Mark

Revision history for this message
larrycraig (craiglarry) said :
#3

Have followed the above solution. While it has not returned my available space to previous 5gi, it has given me .7 gi more space. The response to new available space was very slow. It took two days for the additional space to show up. Maybe I will get more showing later? Otherwise, there must be some other reason for this loss. It's now 2.3 gi, which is certainly not what I expected after removing two old kernels. Seems to me there is still about 3gi unaccounted for.