Linux: How to remove unused kernels in Ubuntu
Open terminal and check your current kernel:
uname -r
DO NOT REMOVE THIS KERNEL!
Next, type the command below to view / list all installed kernels on your system.
dpkg –list | grep linux-image
Find all the kernels that lower than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.
sudo apt-get purge linux-image-x.x.x.x-generic
Finally, run the commands below to update grub2
sudo update-grub2
Reboot your system.
By: penreturn
Additional Useful Information:
Removing Entries from Grub 2 Entries should be removed by editing or removing files in the /etc/grub.d folder. The /boot/grub/grub.cfg file is read-only and should not normally require editing.
Too Many Kernels?
If you are not sure of the kernel you are currently using, in a terminal type uname -r.
Kernels removed via APT (Synaptic, “apt-get remove”, etc.) will automatically update grub.cfg and no user action is required.
A great tool for removing kernels (and menu entries) is Ubuntu-Tweak, a safe and easy-to-use GUI app.
Install ubuntu tweak
Ubuntu-Tweak will be available under Applications > System Tools.
Remove Older Kernel Entries
Select “Package Cleaner” on the left and “Clean Kernel” from the right panel.
Press the “Unlock” button at the lower right, enter your password.
Select from the displayed list the kernel images and headers you wish to remove. The kernel in use is not listed.
Press the “Cleanup” button at the lower right to remove the selected kernel images and headers.
Remove Operating Systems from the Grub menu
Other Operating Systems which have been removed from the computer will also be removed from the menu once “update-grub” is run as root.
Menu items are placed on the Grub2 menu by scripts. If you don’t want other Operating Systems to be entered in the menu, disable /etc/grub.d/30_osprober
Run this command to stop the script from running
sudo chmod -x /etc/grub.d/30_os-prober
DISABLE_30_OS-PROBER=’true’ in /etc/default/grub
Remove Memtest86+ from the Grub Menu
sudo chmod -x /etc/grub.d/20_memtest86+
Run the update-grub command to allow the changes to be incorporated in grub.cfg
By: karthick87