Skip to content
Calcrivo

Yum/DNF Cache Calculator

Estimate DNF/yum metadata and package cache size, and the disk space `dnf clean all` would recover.

Inputs

Total DNF/Yum Cache Size

425.47 MB

Space Recovered by `dnf clean all`

425.47 MB

Repository Metadata Cache

105.47 MB

Downloaded Package (RPM) Cache

320 MB

Step by step

  1. Values used

    Enabled Repositories = 6; Avg Packages Listed per Repo = 15,000; Metadata Overhead per Package (KB) = 1.20; Downloaded RPMs Currently Cached = 40; Avg Cached RPM Size (MB) = 8

  2. Cache size

    cache_size = repos × packages_per_repo × metadata_per_package + cached_rpm_count × avg_rpm_size

  3. Total DNF/Yum Cache Size

    = 425.47 MB

  4. Space Recovered by `dnf clean all`

    = 425.47 MB

  5. Repository Metadata Cache

    = 105.47 MB

  6. Downloaded Package (RPM) Cache

    = 320 MB

How it works

DNF/yum caches two distinct things under /var/cache/dnf (or /var/cache/yum on older systems): repository metadata (the compressed package lists, dependency info and checksums each enabled repo publishes, needed to resolve `dnf install`/`search` without re-downloading metadata every time) and actual downloaded RPM package files (kept after install unless `keepcache=0`, useful for reinstalling or rolling back without re-downloading). `dnf clean all` removes both, recovering their combined size, at the cost of the next operation needing to re-download metadata (and packages, if reinstalled).

Formula

Cache size

cache_size = repos × packages_per_repo × metadata_per_package + cached_rpm_count × avg_rpm_size

Frequently Asked Questions

What's the difference between `dnf clean metadata` and `dnf clean all`?

`dnf clean metadata` removes only the cached repository metadata (forcing a fresh metadata download on the next operation), while `dnf clean all` also removes cached downloaded RPM packages — use `metadata` alone if you just want fresh package lists without losing cached RPMs for possible reinstalls.

Where exactly does DNF store its cache?

Under /var/cache/dnf/, with a separate subdirectory per enabled repository containing both the repo's metadata (repodata/) and any downloaded packages/ subdirectory — `du -sh /var/cache/dnf/*` breaks down usage per repo.

Does clearing the DNF cache affect already-installed packages?

No — clearing the cache only removes downloaded metadata and RPM files used during install/update operations; it has no effect on packages already installed on the system, since those live under the RPM database and filesystem, not the cache directory.

You might also need