Too many old kernels -> how can I delete the old Linux kernels?
1/ I have too many kernels listed in Grub and I wish to remove old ones. I'm not sure how to do it safely.
2/ I've noticed that some are not even listed in Grub but appear when I type dpkg --list | grep linux-image in the terminal (list below).
On the other hand when I type rastanat@
vmlinuz-
It's confusing :-0 (yeah I'm not so technical as you must have guessed it).
I'm using 2.6.35-24-generic (uname -r result) and I also wish to keep the 2.6.35-23 (just in case of a disaster).
Can some one explain to me how to do so and why the kernels lists are different?
Thanks in advance :-)
dpkg --list | grep linux-image gives me the following :
rastanat@
rc linux-image-
ii linux-image-
rc linux-image-
rc linux-image-
rc linux-image-
rc linux-image-
ii linux-image-
ii linux-image-
ii linux-image-generic 2.6.35.24.28 Generic Linux kernel image
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu linux Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Mark Rijckenberg
- Solved:
- 2011-01-17
- Last query:
- 2011-01-17
- Last reply:
- 2011-01-17
Hi,
I created a Linux korn shell script called removekernel
You will need to install the ksh shell first using the following Terminal command:
sudo apt-get install ksh
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.35-22) "
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.32-24
to delete the 2.6.32-24 kernel.
Watch out though: if you use the following command and you do not have any 2.6.32 kernels installed, then you wipe out ALL available Linux kernels:
removekernel 2.6.35
is VERY dangerous as it wipes out all 2.6.35 kernels :-)
Regards,
Mark
Concerning the second question:
"Can some one explain to me how to do so and why the kernels lists are different?"
please create a separate thread for that separate question using the following link:
Xpatnat (xpatnat) said : | #3 |
Thanks Mark for answering question 1.
Kernels clean successfully done :-)
Xpatnat (xpatnat) said : | #4 |
Will post the question 2 in a different thread as suggested.
Thanx
Xpatnat (xpatnat) said : | #5 |
Thanks Mark Rijckenberg, that solved my question.