Limit kernels on RHEL, CentOS and Fedora

As a software tester or developer you are using operating systems such as RHEL, CentOS and Fedora. It may happen that the hard disk space is running at the limit and a further update is no longer possible. An easy way to create free space is to delete the kernel(s) of older versions.


# check for all (old) kernels
$ rpm -q kernel

By default 5 kernels will be stored.

Change configuration

# change configuration
$ vim yum.conf

# limit value and save

# update
$ yum -y update

Delete unused (old) kernels

# install yum-utils
$ yum install yum-utils

# cleanup with value for old kernels you want left
$ package-cleanup --oldkernels --count=2