How to Remove Old Linux Kernels; At some point in time, almost every Linux user will have updated their kernel image. After you've used Linux with the new kernel image for a while and you're content that everything is working properly, you might want to remove the old Linux version or images that still reside on your system and appear as grub boot options.
Over time, as you update your Linux system, old kernel versions may accumulate on your system. It's generally a good practice to remove old kernels to free up disk space and keep your system tidy. Here's a step by step guide on how to remove old Linux kernels on a Debian based system (such as Ubuntu):
Table of Contents
Remove Old Linux Kernels (Ubuntu or Debian)
The following process explains how to entirely remove the old Linux image version which in turn also unclutters your grub menu. Note that the newer process is all inclusive and automatically updates grub once it has finished.
Removing unused Linux kernels on Debian or Ubuntu
- Open a terminal window by pressing Ctrl+Alt+t
- To automatically remove and update, type or copy and paste the following:
sudo apt autoremove
Removing Old Linux kernels on older Debian or Ubuntu
The following steps are only useful on old versions of Ubuntu or Debian or where "autoremove" didn't work. Note that you can also find and remove linux-headers using this method.
- Open a terminal window Ctrl+Alt+t
- To list all installed kernel images on your system, type or copy and paste the following into the terminal and then press Enter:
dpkg --list | grep linux-image
- Then, to see which kernel image you are currently running:
- To remove kernel images that are no longer in use, replacing VERSION with your actual kernel image version, use the following:
sudo apt-get remove linux-image-VERSION
- To remove the old Linux headers and Linux modules as well:
sudo apt-get remove linux-headers-VERSION linux-modules-VERSION
- Finally, to update grub:
Alternate older graphical method
Make a note of your old kernel version images from the Grub Menu during system startup. Then once you're up and running; from the graphical desktop environment:
- Press Alt+F2 and then type Synaptic
- From the Menu select Search and type linux-image in the Search box.
- Locate your old linux-mage from the list for example: linux-image-x.x.xx-xx-xxx
- Right Click the images you would like to remove, select Mark for Complete Removal and then click apply to remove the old image.
- Open a terminal Ctrl+Alt+t, type the following and then press Enter
Next time you reboot the Grub menu will contain only the current linux kernel image. This concludes the simple process to remove old Linux kernels or removing unused Linux kernels.