AlmaLinux 9: installing packages without internet
Test scope
Section titled “Test scope”Executed in an almalinux:9 container (AlmaLinux 9.8, aarch64, dnf 4.14.0): installing createrepo_c, dnf install --downloadonly --destdir=… tree, rpm -qp --qf for the package architecture, createrepo_c, writing a local repo and running --disablerepo="*" --enablerepo=local-offline install tree, rpm -q tree, plus reproducing “install another package after downloading”. Log: plans/content-expansion/evidence/logs/alma-offline-updates.log.
Full dependency resolution, GPG signature verification and real network isolation were not tested here and are labelled accordingly.
Step 1: check the architecture first
Section titled “Step 1: check the architecture first”uname -mrpm -qp --qf "%{NAME} %{ARCH} %{VERSION}\n" /srv/off2/*.rpmaarch64tree aarch64 1.8.0The most common offline failure is not a missing repository but an architecture or major-version mismatch: packages fetched as x86_64 cannot be installed on an aarch64 host. Compare uname -m with rpm -qp before anything else.
Step 2: stage the packages
Section titled “Step 2: stage the packages”sudo dnf -y install --downloadonly --destdir=/srv/off2 treels /srv/off2tree-1.8.0-10.el9.aarch64.rpmDo not install anything else right after this. Observed here: running dnf -y install wget next left /srv/off2 empty, because dnf cleaned the staging directory after the following successful transaction. Install tooling such as createrepo_c first, then run --downloadonly.
Step 3: build metadata and point dnf at the directory
Section titled “Step 3: build metadata and point dnf at the directory”sudo createrepo_c /srv/off2printf '[local-offline]\nname=Local offline\nbaseurl=file:///srv/off2\nenabled=1\ngpgcheck=0\n' \ | sudo tee /etc/yum.repos.d/local-offline.reposudo dnf clean allcreaterepo_c writes repodata/, which is what makes the directory a repository; without it a pile of rpms only yields No match for argument.
Step 4: install with only the local source enabled
Section titled “Step 4: install with only the local source enabled”sudo dnf -y --disablerepo="*" --enablerepo=local-offline install treerpm -q treeInstalled: tree-1.8.0-10.el9.aarch64Complete!tree-1.8.0-10.el9.aarch64On an isolated host every other repo is unreachable, so --disablerepo="*" keeps dnf from waiting on timeouts.
Step 5: verify offline (more important than “it installed”)
Section titled “Step 5: verify offline (more important than “it installed”)”rpm -q treerpm -V treednf --disablerepo="*" --enablerepo=local-offline repoquery --requires tree | headrpm -q prints a version, rpm -V prints nothing (files unmodified), and the dependency query returns output. All three must pass. Whether dependencies are truly satisfied depends on the actual install: tree has none here, but packages such as nginx require their dependencies to have been downloaded too.
Common traps
Section titled “Common traps”- Wrong architecture: run
uname -mbefore downloading;aarch64andx86_64packages are not interchangeable; - Installing something before building the repo: the staging directory is cleaned (observed here); order is tooling → download → createrepo;
- Leaving
gpgcheck=0in production: carry AlmaLinux’s GPG key and usegpgcheck=1with a localgpgkey=file://.
Practice: move nginx to an isolated host
Section titled “Practice: move nginx to an isolated host”Prerequisite: connected host A and isolated host B, same architecture, both AlmaLinux 9.
# Asudo dnf -y install createrepo_csudo dnf -y install --downloadonly --destdir=/srv/off nginxsudo createrepo_c /srv/offtar -C /srv -czf off.tgz off# Bsudo tar -C /srv -xzf off.tgz# point local-offline.repo at /srv/off, then:sudo dnf -y --disablerepo="*" --enablerepo=local-offline install nginxChecks:
rpm -q nginx→ prints a versionrpm -V nginx→ no outputdnf --disablerepo="*" --enablerepo=local-offline repoquery --requires nginx | wc -l→ same count asdnf repoquery --requires nginx | wc -lon host A
常见问题
Why does dnf say No match when the rpm is in the directory?
Usually because there is no repodata: the directory is just a folder. Run createrepo_c in it, then dnf clean all so dnf re-reads the metadata.
The downloaded files disappeared after a while?
In this test, running any successful dnf transaction afterwards (installing wget, for example) cleaned the staging directory. Install tools such as createrepo_c first, then run --downloadonly.
Should gpgcheck stay enabled on an isolated host?
Yes. Bring AlmaLinux's GPG public key along and set gpgcheck=1 with gpgkey=file:///...; keeping gpgcheck=0 long term drops signature verification.
Next steps
Section titled “Next steps”- Repositories and SIG variants: AlmaLinux repositories
- Transaction rollback: dnf history undo
- Conflicting repos (page pending):
/en/repo-priority/