This is a beginner’s guide shows how to remove the old kernels in Ubuntu or Linux Mint to free up your disk space and / or clean up the boot menu.
Ubuntu pushes Linux Kernel updates regularly through the security & updates repositories. You’ll have more than one Kernels on your system after using Ubuntu for a period of time and install system updates regularly.
If you want to remove the old kernels, here are 5 ways that may help!
1. Remove Old Kernels via Apt command (Safe Way)
The easiest way to remove old kernels is using the apt
command. It will however keep the latest two installed Kernels as well as Ubuntu Mainline Kernels if installed.
Open terminal
and run apt command to remove old kernels if any:
sudo apt remove --auto-remove
2. Remove old Kernels via Ubuntu Cleaner. (Safe Way)
Ubuntu Cleaner is a simple system cleaning tool, which has an option to remove old Kernels. It allows to remove ALL Kernels other than the current running one. However, it does not handle the Ubuntu Mainline Kernels too.
To install Ubuntu Cleaner, run following commands one by one to get it from the official PPA:
sudo add-apt-repository ppa:gerardpuig/ppa
sudo apt update
sudo apt install ubuntu-cleaner
3. Remove old Kernels via Mainline installer:
The Ubuntu Mainline Kernel Installer is a free and open-source tool forked from ukuu, allows to install, remove, and purge Ubuntu Mainline Kernels (see the previous link).
It also lists all installed Ubuntu Kernels, and allows to remove them easily via single click.
KEEP in mind don’t remove the current running kernel. You can find it in bottom of the app window, or running uname -r
command in terminal.
To install the tool, run following commands one by one to get it from the official PPA.
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt update
sudo apt install mainline
4. Remove old kernel packages via Synaptic:
Synaptic is a graphical tool for apt package management system. With it, you can manually search for and remove old kernel packages.
Install Synaptic from Ubuntu Software, then do following steps one by one.
- Click search button, and search for ‘linux-image generic’.
- Click on the ‘S’ icon to re-order output list.
- Select the kernel packages (press & hold Ctrl to select more.) you want to remove.
- Right-click on highlighted package and choose ‘Mark for removal’
- Finally click ‘Apply’.
NOTE: don’t remove the current running kernel packages (run uname -r
to get it). And you may also do previous steps with ‘linux-header’ packages.
5. Remove old kernel packages manually via Linux command:
First open terminal
and run command to list available Kernel packages:
dpkg --list |grep linux-image
Then run dpkg --purge
to remove a selected package. The command may fail sometimes due to dependency issue, you can try apt remove
command instead.
sudo dpkg --purge linux-image-5.4.0-48-generic
AGAIN don’t remove the current running kernel (uname -r
).