TT Lab
Blog Get started
Learn Learning paths Courses

RHEL-Family Administration

createrepo_c and repodata

Continue in TT Lab

In one line

createrepo_c scans an rpm directory and builds repodata/. The repomd.xml inside it is the table of contents that points to the other metadata files.

Why this exists

Merely copying RPM files into a directory does not make it a dnf repository. dnf does not open every package each time; it looks up the versions, dependencies, and file lists in repodata. So if you add packages and do not refresh the metadata, the files on the server and the list the client sees differ. If you know this difference, you can tell cache and permission problems apart from a missed repository creation.

How it works

dnf install -y createrepo_c
createrepo_c /srv/repo/labhub

ls -1 /srv/repo/labhub/repodata/
# repomd.xml
# <checksum>-primary.xml.gz
# <checksum>-filelists.xml.gz
# <checksum>-other.xml.gz
File Contents
repomd.xml The table of contents. The location, checksum, and time of each metadata file
primary Name, version, dependencies, summary
filelists The list of all files a package contains
other changelog

The reason file-based search such as dnf provides '*/nginx.conf' works is filelists.

The checksum prefix before the file names is the result of --unique-md-filenames (the default). It prevents the incident in which an intermediate proxy or CDN returns an old copy. The file name changes with the content, so the cache cannot get confused.

Main options

Option Behavior per the documentation
--update "Reuse existing metadata for rpms that have not changed, judged by file size and mtime"
--workers N Number of workers that read rpms
-g, --groupfile Include a comps group file
-s, --checksum The checksum type of repomd and packages. Default sha256
--compress-type bz2, gz, zck, zstd, xz
-i, --pkglist A file listing the packages to include
--retain-old-md N Number of old repodata to keep
-x, --excludes Exclude patterns

-d/--database (creating sqlite) is deprecated. If you see this option in an old procedure document, you can delete it.

Tying --pkglist to the manifest is a good practice. If you use the import manifest as the pkglist as it is, it structurally prevents the incident where the list and the actual repository disagree.

Updating

After adding packages, always rebuild the metadata.

createrepo_c --update /srv/repo/labhub
dnf clean expire-cache
dnf repolist

Forgetting --update is the number one cause of the most frequent report on air-gapped networks. The files are visible, but dnf does not know.

The repo file and verification

[labhub-local]
name=LabHub local (snapshot 2026-08-20)
baseurl=file:///srv/repo/labhub
enabled=1
gpgcheck=0
metadata_expire=-1

Three checks that it works.

dnf repolist -v
dnf repoclosure --repo=labhub-local
dnf install --assumeno <패키지>

dnf repoclosure lists packages that have dependencies that cannot be resolved inside the repository. It is the best tool to use as a gate before an import.

createrepo_c /srv/bundle/rpms
dnf repoclosure --repofrompath=bundle,/srv/bundle/rpms --repo=bundle

--repofrompath specifies a repository temporarily without creating a .repo file. It is useful in verification scripts.

Cleaning up old packages

dnf repomanage --old --keep 2 /srv/repo/labhub
dnf repomanage --old --keep 2 /srv/repo/labhub | xargs -r rm -v
createrepo_c --update /srv/repo/labhub

How many you keep is the rollback range. If the import interval is once a month and you keep 3, about 3 months of rollback is possible.

What it looks like in the field

A snapshot date in the repository display name. If you write it like name=... (snapshot 2026-08-20), six months later one dnf repolist -v line can pin down the point in time.

"I put it in but it doesn't show": three layers, in order

For a package to become visible to a client, it must pass through three layers. First, the server directory's index. Just copying an rpm file in does not make that package appear in the table of contents (repomd.xml) or primary; you must reindex. Second, the client's cache. dnf does not read the repository every time but uses the table of contents it downloaded. On air-gapped networks it is common to set "do not fetch again on its own" as policy with metadata_expire=-1, so even after you fix the server, this client sees the old list until an operator refreshes it. Third, the repository definition. It is common for an exclude rule added during a past incident to look only at the beginning of names and hide new packages too.

Since the symptom is the same, separate the layers by evidence. Whether it is in the server's index you can tell by reading primary directly, or by asking the repository with a temporary cache that does not touch this server's cache. If it is there but not visible with the usual query, it is either the cache or the definition. The cache is revealed by comparing the refresh time in the per-repository detailed list with the revision in the table of contents, and the definition by expanding the repository's actual configuration.

One thing to watch out for. When stuck, you will want to wipe the whole cache first. That may make the symptom disappear, but the evidence of what the cause was disappears with it, and a missed index or an exclude rule remains and happens again next time. Look first, then fix.

What you will do in the next lab

You collect rpms and build a repository with createrepo_c, write a .repo file, enable only that repository and install, and after adding a package, refresh it with --update. In the final step, you tell apart an incident in which three mirrors are each blocked at a different layer.