I have many kernels in the boot menu. I want some of them, but rest should be removed/uninstalled. How can I select and keep the kernels I want and remove rest of them? I should be able to remove the kernel headers as well
I have many kernels in the boot menu. I want some of them, but rest should be removed/uninstalled. How can I select and keep the kernels I want and remove rest of them? I should be able to remove the kernel headers as well
What I do is:
Delete or Move the Kernel versions you do not want from /boot
to another place. For example in my case I have:
For abi files I have: abi-3.0.0-12
, abi-3.0.0-13
, abi-3.0.0-14
, abi-3.0.0-15
For config files I have: config-3.0.0-13
, config-3.0.0-14
, config-3.0.0-15
For the rest I also have the same thing. About 4 or 5 versions of it. So I literally delete (or more recommended it is to move) the files to another place and leave the last version and the previous version for that. For example, for the abi files I would leave the last ones which are abi-3.0.0-14
and abi-3.0.0-15
Same goes for the rest, you should have several versions of abi, config, initrd.img, System.map, vmcoreinfo and vmlinuz. Delete/Move all but the last 2.
then execute sudo update-grub
and reboot. You should now have only the last 2 shown in the list.
NOTE - It is more recommended to Move the files instead of deleting in case you have a problem later.
UPDATE: As suggested by Lekensteyn using dpkg -S /boot/filename
will show you what package is responsible for the filename in boot. For example: dpkg -S /boot/abi-3.0.0-12-generic
will show you:
linux-image-3.0.0-12-generic: /boot/abi-3.0.0-12-generic
which means that the package linux-image-3.0.0-12-generic is responsible for installing that specific file. If you want to see the whole linux-image files do something like:
sudo apt-cache search linux-image
or more friendly sudo aptitude search linux-image
You then can use sudo apt-get remove PACKAGE
for each one but of course will take some time since there are several. A quick GUI way is Synaptic since you can select multiple packages and then just mark them for deletion.
Another GUI way is Ubuntu Tweak (Mentioned by TomTasche) which offers an easy way to remove the old kernels:
I should mention that when I started deleting kernel files Ubuntu-Tweak did not exist. After using it and booting again without any problem I can say that you can use it and not be afraid of some problem since it removes the packages the same way as purging/removing them with aptitude or apt-get. What I still recommend is leaving the previous version of the kernel, so if you have 3.0.0-15 as the latest, keep also 3.0.0-14 just in case something happens with 15 you can have a backup by going to 14.
To install ubuntu-tweak:
sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak