Every time Ubuntu installs a new Linux kernel, the old one is left behind. This means that if you are regularly updating an Ubuntu system the Grub boot menu becomes longer and longer with kernels you don’t need anymore.
The old kernels are deliberately left installed and on the menu so you can boot a previous kernel if you have trouble with a new one. But if the new one works, you can safely uninstall the old kernel, which will also result in the Grub menu being cleaned up.
First you need to find out what your current kernel is. Open a terminal and run the following command:
uname -r
It will print the version of the Linux kernel you are running, this is the one you want to keep. It should look something like this:
2.6.20-16-generic
Open the Synaptic package manager from the System->Administration menu.
Click the “Search” button on the tool bar and search for linux-image-2.
The results should show every available and installed kernel. A green box on the left indicates that the package is installed. The only linux-image you want installed is the latest one. Find the package corresponding to the kernel to you running currently (this is the kernel you found in the terminal window). Make sure you keep that one. Now you can uninstall the old kernels from the list by clicking their boxes and selecting “Mark for Removal”.
Caution! Be careful of what you remove. Ensure that you don’t remove your current kernel, or anything that is not a linux-image. It is possible to break Ubuntu if you remove the wrong kernel.
Click the apply button on the tool bar to complete the changes.
Your computer and Grub menu should now be free of old kernels.


I usually also keep the second-to-last, just in case the first one breaks.
Greatï¼
Great Cool !but what if i break the system,i wud prefer to keep the kernel unless the list remains slim.I think there’s a GReat Need Now for ubuntu thinking about System restore feature of Xp.There is alternative,u can delete the entries from GRub wont hurt.Keep Ubuntu”’ing.
So Great! I just needs to remove the kernels I installed wrongly.
Installed hardy over gutsy, from the net update download. Found both 2.5.22.14 and 2.6.24.16 loaded in grub. Would not boot with 24.16 only with 22.14. Spent hours on forums to attempt to correct. Lucky found this site and the simple logical solution. Removed 22.14 and all is well. Thanks from me – a newbie!
I also uninstall linux-headers-xx (of course not the current one)
[...] å•击“应用(Applyï¼‰â€æŒ‰é’®ï¼Œå®Œæˆæ“ä½œã€‚å½“ä½ ä¸‹æ¬¡å¼€æœºæ—¶ï¼Œä½ å°±ä¼šå‘现GRUBç›®å½•ä¸‹é‚£äº›å¤šä½™çš„å†…æ ¸é€‰é¡¹éƒ½æ²¡æœ‰äº†ã€‚ 原文地å€ï¼šhttp://tombuntu.com/index.php/2007/10/17/remove-ubuntu-kernels-you-dont-need/ [...]
thanx it was useful …
thank U sooooOOooooo much …
wish u the best …
Oh I’ve just met the same problem with Norm! I’ll try it then. Thank you all guys.
Thank you for the article..
Its just that many ubuntu newbies know something about synaptic but they dont know that even kernels are managed by it
Thanks!!!
Thanks for the clear instructions for ubuntu. I just switched from XP and so, so much of linux/ubuntu instruction out there is not geared toward those of us who didn’t have LINUX as our first language growing up.
Thanks!
Josh in Indianapolis
thanks so much much neater without all those old kernels cluttering up my GRUB menu
After upgrade, just use apt-get autoremove to remove the old kernel packages.
Manually delete the initrd.img.old/vmlinuz.old in /, as well as in /boot, edit grub menu.
Make sure u do it carefully, do not delete the current kernel:)
[...] ????????. [...]
After installing new kernel I choose this kernel in grubmenu and see ubuntu download. But… Suddenly the screen switches off (gets dark). The onle thing I can do then, is to press reset button in order to reboot and choose the old kernel. Why doesn’t the new one work?
Thanks, my grub menu was getting really full with all the different kernels and sometimes I boot to my windows xp install and it was no longer even on the first screen. Got some of the old kernels removed now, thanks. I keep the 2nd to oldest for backup just in case. Its saved me before.
When trying to uninstall an older kernel, the synaptic package manager ask also permission to remove other modules, for instance when uninstalling:
linux-image-2.6.24-19-generic
the following modules need to be removed too:
linux-restricted-modules-2.6.24-19-generic
linux-ubuntu-modules-2.6.24-19-generic
Is it safe to remove these, or will this mess up my system?
[...] Remove Ubuntu Kernels You Don’t Need | Tombuntu (tags: ubuntu kernels) [...]
thanks a lot for this tutorial! was very helpful! regards from Portugal
an unusually succint and understandable “HOW TO” TA
it’s a good idea but make sure to keep at least one old kernel. sometimes things go bad and the only way to fix it is to load the old kernel.
I’m also starting to collect old kernels, which really clutter up my GRUB start menu, but what about the other old packages? Other than removing everything that is linux-image, as per the article’s instructions, do you remove the other kernel-specific files that do not have “linux-image” in their names?
E.g., would the removal list would look like:
linux-image-XXX-generic
linux-headers-XXX
linux-headers-XXX-generic
linux-restricted-modules-XXX-generic
where XXX is the older version(s)
Thanks for the help. I then got a dialog asking what to do about the Grub menu. I really didn’t know what option to choose so I picked to keep the list as it is. I know I can manually edit it, but it would have been nice to see an option like: “Update to include only installed Kernels” or something like that.
This cleared some things up for me. I had been manually editing my grub list to remove older kernels entries, but not actually removing the old kernels from Ubuntu. LOL, everytime I upgraded my grub list was repopulated with all of the outdated kernels, which were #rem out. At least now I know why it was being repopulated, and how to keep it slim and trim. I’ve got a dual boot setup between Ubuntu and Vista/XP where Ubuntu is on an old IDE drive and Vista/XP are on a raid setup. I’m going to print my grub list before removing the any entries just in case it overwrites my Vista/XP entry.
[...] sumber : http://tombuntu.com/index.php/2007/10/17/remove-ubuntu-kernels-you-dont-need/ [...]
[...] it couldn’t be because I installed the XFCE window manager (which I removed anyway). From Tombuntu, I learned that I could free up more space by removing old unused [...]
thank you for the clear + good informations, it works !
I prefer Synaptic then doing it “by hand” like
apt-get remove linux-headers-2.6.20-15 linux-headers-2.6.20-15-generic linux-image-2.6.20-15-generic –purge
greetings from France
command line would be great. Anything in linux should be done in the command line.
nice
its work
thank you
[...] Reference: Remove Ubuntu Kernels You Don’t Need [...]
it works yeeeeahhhh thank you
This is by far the best guide I’ve found!!!
Most of all guides around just tell you how to erase the grub entries but this one explains how to uninstall the old kernels…
Thanks a lot!!!
Thanks. It worked like a charm in Ubuntu 9.04
How to uninstall a new kernel?
Suddenly I couldn’t boot from the usual kernel in Ubuntu 9.04 64-bit and am using an older one. I would like to reinstall the newer one.
In Synaptic I see the following packages installed:
linux-headers-2.6.28-15
linux-headers-2.6.28-15-generic
linux-image-2.6.28-15-generic
linux-restricted-modules-2.6.28-15-generic
linux-image-2.6.28-11-generic
linux-restricted-modules-2.6.28-11-generic
I have noticed that the older packages have no dependencies. But they are the ones in use. However, if I try to uninstall all the newer version packages, Synaptic will also uninstall:
linux-headers
linux-headers-generic
linux-image-generic
linux-restricted-modules-generic
dkms
How should I reintall the new kernel in order to make it work? Which 2.6.28-15 packages do I have to remove and how?
Thanks so much,
jmm
I actually just enabled the jaunty-proposed repository and updated the newer kernel.
I would have liked to update to the 2.6.30 kernel but I am too much of a newbie to know the benefits / risks.
Thank you for the easy patch, it helps me save space on my 4GB USB flash device!
One question though:
Does GRUB get updated automatically or does it need to be edited manually?
(And what about those of us who don’t run Grub on a system booting up a Linux kernel)?
“Other than removing everything that is linux-image, as per the article’s instructions, do you remove the other kernel-specific files that do not have “linux-image” in their names?
E.g., would the removal list would look like:
linux-image-XXX-generic
linux-headers-XXX
linux-headers-XXX-generic
linux-restricted-modules-XXX-generic
where XXX is the older version(s)”
Yeah, you might as well. Frees up a whole bunch of disk space
Doesn’t sudo apt-get autoremove get rid of them even if the entry remains in grub’s menu ?
I just removed all the old kernel-specific files (except for the current and previous one), and things restarted just fine. Since I’m running with only 20 GB of disk space, the half a gig of removed files is good.
Thanks a lot. I was able to remove the older version from the grub menu after following above procedure
Sridharan.
worked like a charm on ubuntu 9.10 – appreciate the help
epic fail. now it won’t boot. gotta re-load. lost ALL my data.
For some reason, Synaptics doesn’t show the kernels when I search for “linux-image-2″ but it does when I take of the “-2″ although all the packages do begin with “linux-image-2″. Just a weird little thing I wanted to point out.
thanks buddy ,i was looking for the same
i am installing all but the latest ones of linux-image in synaptic manager .totally it requires 2.2 gb.tell me if this is updating the kernel.
to answer some of the questions in the comments -
[reposting as the <kernel number> were stripped]
1 to automatically update the list of kernels there are 2 ways
A the best is to upgrade to grub-2
sudo apt-get install grub2
B when you are given a list of alternatives how to modify /boot/grub/menu.lst, look at the ’side-to-side difference’; although you’ll need to understand how to read a diff file for that, it’s relatively self-evident; alternatively normally ‘install the package maintainer’s version’ is quite sufficient, as it is usually a list derived from kernels + alternate OS’s found
2 apt-get autoremove won’t necessarily remove older kernels
3 for the message
uninstalling:
linux-image-<kernel number>-generic
the following modules need to be removed too:
linux-restricted-modules-<kernel number>-generic
linux-ubuntu-modules-<kernel number>-generic
go ahead, it’s perfectly normal, no cause for concern, you won’t need the kernel modules for that kernel once you’ve no longer got that particular kernel
try to avoid uninstalling however
linux-headers
linux-headers-generic
linux-image-generic
linux-restricted-modules-generic
dkms
when synaptic/apt-get is saying that, it’s a sign you’ve been checking the most recent kernel, that’s a no-no!
Best
Mark
I personally use Ubuntu Tweak to remove all the old kernels without any problems.
One command:
sudo aptitude purge ~ilinux-image-.*\(\!`uname -r`\)
In some cases keeping an old kernel might make sense.
having an old kernel installed with drivers not available anymore makes it able to use “old/unsupported” hardware for a longer time. that is, until kernel and userland start diverging too much.