4.3.7. Removing old kernels on CentOS and Fedora (freeing up space in / boot)

Warning!

The kernel removal procedure is irreversible. Before uninstalling, be sure to test the current kernel for performance.

You can view a list of all installed kernels using the command:

rpm -q kernel

Install yum-utils:

yum install yum-utils -y

Remove unnecessary kernels by running:

package-cleanup --oldkernels --count=2

Where --count=2 — the number of system cores that need to be left (in the example — 2).

To automatically remove kernels during an update, you must change the parameter installonly_limit in /etc/yum.conf:

installonly_limit=3

Warning!

Cannot be greatly reduced installonly_limit (especially below 2), as this can provoke situations in which the server will stop working after the update.
Content