When you’ve got servers running for several years, their kernels have been replaced many times for security reason. You keep getting new ones regularly in the /boot partition until it becomes a problem.
To get the list of the old kernels kept, type:
# rpm -q kernel kernel-3.10.0-123.8.1.el7.x86_64 kernel-3.10.0-123.9.2.el7.x86_64 kernel-3.10.0-123.9.3.el7.x86_64 kernel-3.10.0-123.13.1.el7.x86_64 kernel-3.10.0-123.13.2.el7.x86_64
The yum command provides you two solutions: one temporary and one permanent.
The temporary solution
The package-cleanup command offers several interesting options.
To install the package-cleanup command, type:
# yum install yum-utils
To list dependency problems in the local RPM database, type:
# package-cleanup --problems No Problems Found
To display the RPMs that are not relied upon by any other RPM, type:
# package-cleanup --leaves NetworkManager-libreswan-0.9.8.0-5.el7.x86_64 libertas-sd8686-firmware-20140804-0.1.git6bce2b0.el7_0.noarch ... net-snmp-libs-5.7.2-18.el7.x86_64
To list installed packages which are not available from currently configured repositories, type:
# package-cleanup --orphans libtiger-0.3.4-7.el7.nux.x86_64 python-coverage-3.7-3.el7.nux.x86_64
To scan for duplicates in the local RPM database, type:
# package-cleanup --dupes
Note: If you get any duplicate RPMs in the local database, you can use the –cleandupes option to remove them.
Finally, the –oldkernels and –count options allows you to define the number of old kernels to keep.
To remove all the old kernels except two, type:
# package-cleanup --oldkernels --count=2
The permanent solution
Edit the /etc/yum.conf file and set the installonly_limit variable:
Note: The default value is 5.
Sources: Inspired from the Lintut website and the package-cleanup man page.
You can also read a tutorial about maintaining Yum and boosting its performance.
Leave a Reply
You must be logged in to post a comment.