2018-06-11

Safely Remove Unused Kernels In RHEL/CentOS/Fedora

There are three main ways to do it:

  1. Use package-cleanup command from yum-utils
  2. Use Fedora's dnf remove combined with dnf repoquery
  3. Set maximum number of installed kernels in /etc/yum.conf file
First:
# yum install yum-utils
# package-cleanup --oldkernels --count=2
Second:
# dnf remove $(dnf repoquery --installonly --latest-limit 2 -q)
Third:
# vim /etc/yum.conf
installonly_limit=3  #set kernel count

See also: