Systems with limited network access still need a source for software and its dependencies. On Fedora and RHEL-family systems, a local DNF repository makes a directory of RPMs available for installation without a public mirror.

The connected builder and the client should use the same distribution release and architecture. The builder needs write access to a mounted filesystem the client can read. A file: URL points to that filesystem as mounted on the client.

The client needs to trust the keys that signed the RPMs before it can install them. The repository maintainer should control write access to the filesystem because it holds both the packages and the index DNF uses to find them.

Steps to create a local DNF repository:

  1. Install createrepo_c on the connected builder.

    On DNF4 systems such as RHEL and CentOS Stream 9 and 10, use sudo dnf install createrepo_c dnf-plugins-core for the download plugin. DNF5 includes the download command.

    $ sudo dnf install createrepo_c
  2. Create an internal directory under the builder's mount point, using /mnt/repository as the example path.

    If your mount point differs, substitute its path here and in the next two commands. Paths with spaces need single quotes in shell commands and %20 in the file URL.

    $ mkdir /mnt/repository/internal
  3. Download the signed RPM for a package absent from the client, using its name in place of tree here and in the client install command.
    $ dnf download --destdir=/mnt/repository/internal tree

    If the client also needs dependencies, use the form below. It includes dependencies already installed on the builder.

    $ dnf download --resolve --alldeps --destdir=/mnt/repository/internal tree
  4. Generate the repository metadata in the directory containing the RPMs.
    $ createrepo_c /mnt/repository/internal

    DNF reads the package index from the resulting repodata directory.

  5. Open a new file named /etc/yum.repos.d/internal-local.repo on the client.

    The filename and the internal-local repository ID must both be unused. If either is already in use, stop before changing the existing configuration.

    $ sudoedit /etc/yum.repos.d/internal-local.repo
  6. Enter the repository definition with the absolute path to the RPM directory on the client in baseurl.
    [internal-local]
    name=Internal local packages
    baseurl=file:///mnt/repository/internal
    enabled=0
    gpgcheck=1
    skip_if_unavailable=0

    enabled=0 keeps the repository out of routine DNF operations. gpgcheck=1 requires a trusted package signature.

  7. Save the file.
  8. Close the editor.

    sudoedit writes the repository file when the editor closes.

  9. Start the package installation on the client using only internal-local.

    This changes the client's installed software. If DNF reports an untrusted key, stop until the client trusts the approved signing key.

    $ sudo dnf --refresh --repo=internal-local install tree

    --repo=internal-local selects only the local repository for this transaction. If DNF cannot load the repository, check that the client's mount and baseurl point to the directory containing repodata, then retry the installation.

  10. Answer y at the confirmation prompt only if the Repository column shows internal-local for the packages being installed and the listed changes are expected.

    DNF prints Complete! when it finishes installing the packages from the local repository.

Share this guide