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:
- Install
createrepo_con the connected builder.On DNF4 systems such as RHEL and CentOS Stream 9 and 10, use
sudo dnf install createrepo_c dnf-plugins-corefor thedownloadplugin. DNF5 includes thedownloadcommand.$ sudo dnf install createrepo_c
- Create an
internaldirectory under the builder's mount point, using/mnt/repositoryas 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
%20in the file URL.$ mkdir /mnt/repository/internal
- Download the signed RPM for a package absent from the client, using its name in place of
treehere 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
- Generate the repository metadata in the directory containing the RPMs.
$ createrepo_c /mnt/repository/internal
DNF reads the package index from the resulting
repodatadirectory. - Open a new file named
/etc/yum.repos.d/internal-local.repoon the client.The filename and the
internal-localrepository 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
- 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=0keeps the repository out of routine DNF operations.gpgcheck=1requires a trusted package signature. - Save the file.
- Close the editor.
sudoeditwrites the repository file when the editor closes. - 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-localselects only the local repository for this transaction. If DNF cannot load the repository, check that the client's mount andbaseurlpoint to the directory containingrepodata, then retry the installation. - Answer
yat the confirmation prompt only if theRepositorycolumn showsinternal-localfor the packages being installed and the listed changes are expected.DNF prints
Complete!when it finishes installing the packages from the local repository.