Saucepan

How to guides and technology tutorials for Amazon AWS, Google Cloud, Linux, macOS, Windows, and other systems

How to remove old kernels on CentOS

Published: 26 February 2017
Updated: 29 April 2020
Filed Under: CentOS

If you need to reduce disk usage by cleaning up your /boot partition, or limit the number of items in your boot list, you can remove old kernels, as well as stop yum from keeping old versions by following this simple tutorial.

List all installed Linux kernel images

You can see a list of all currently installed kernel images and verify which kernel release you're using with the following commands.

rpm -q kernel
uname -r

Install yum-utils

The package yum-utils contains package-cleanup which will be used to uninstall old unused Linux kernel images.

sudo yum install yum-utils

Uninstall old kernels

Replace number with the maximum number of kernels you would like to keep.

sudo package-cleanup --oldkernels --count=number

Modify Yum configuration

Edit /etc/yum.conf file and change installonly_limit to the maximum number of kernel images you would like kept installed.

sudo vi /etc/yum.conf