Clean up /var/cache/yum constantly filling file system in CentOS and RHEL Linux

At work recently we hit one of those common system admin problem on a server installed by some colleagues who have weirdly set a very small /var/cache/yum separate partitioned spaced at only 10Gb on a Redhat Enterprise Linux 7.8 Linux. The OS install guys original thinking was that this machine is to be used just for a very simple cluster and to run a Web Hosting services, a Haproxy Clustered service with PCS + Heartbeat and Corosync, but they did not estimated properly, that redhat comes its own rhnsd and updates gets pushed frequently to the machine and the lack of cleaning up the updated / installed rpms would soon leave the system into a full /var/cache/yum partition.

The gradual increase with time even though with few megabytes each and every month is normal behavior as the cache would increase its size based on the frequency of syncing with the yum server.

On this specific machines besides the rhnsd there is also a spacewalk (Free and Open Source systems management) which usually is installed to orchestrate multiple installed systems to centralize installation updates and monitoring of rpm packages.
also has its own way to produce its own files in /var/cache/yum with creating a repository clones of defined repository directories.


The normal way to clean up space as we all know is then to do something with yum:

[test@rhel ~]$ yum clean
Loaded plugins: fastestmirror, langpacks
Error: clean requires an option: headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all
[test@rhel ~]$

Usually to clean up a bit of space and get rid of partition full problem you can do:

[test@rhel ~]# yum clean metadata

This cleans up any xml metadata that may have been cached from any enabled repository.

[test@rhel ~]# yum clean all

This should clean up all rpms and metadata.

In cases where this works you should frequently re-run it on the machine or set it on a cron job to periodically reduce space occupied by useless downloaded .rpms.

However sometimes this simple solutions does not work

Share this on:

Download PDFDownload PDF

Leave a Reply

CommentLuv badge