How to Remove Old Linux Kernels

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.

Remove Old Linux Kernels
Easily Remove Old Linux Kernels from Ubuntu

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):

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

  1. Open a terminal window by pressing Ctrl+Alt+t
  2. 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.

  1. Open a terminal window Ctrl+Alt+t
  2. 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
  3. Then, to see which kernel image you are currently running:
    uname -r
  4. 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
  5. To remove the old Linux headers and Linux modules as well:
    sudo apt-get remove linux-headers-VERSION linux-modules-VERSION
  6. Finally, to update grub:
    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:

  1. Press Alt+F2 and then type Synaptic
  2. From the Menu select Search and type linux-image in the Search box.
  3. Locate your old linux-mage from the list for example: linux-image-x.x.xx-xx-xxx
  4. Right Click the images you would like to remove, select Mark for Complete Removal and then click apply to remove the old image.
  5. Open a terminal Ctrl+Alt+t, type the following and then press Enter
    update-grub

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.