TT Lab
Blog Get started
Learn Learning paths Courses

RHEL-Family Administration

Completing an Air-Gap Transfer

Continue in TT Lab

Goal

You build an import bundle, verify it with the manifest, pack it into an archive and unpack it, set up a repository, and install from it alone. After passing through the entire air-gapped network procedure in one go, in the final step you tell apart and fix an incident in which three import repositories each fail for a different reason.

Why it matters

An import medium must not hold only rpms. It needs all six: rpm, repodata, GPG key, manifest, checksums, and an install procedure document, and the ones most often missing in practice are the manifest and the GPG key.

And verification must be two-way. Is every file in the manifest on the medium (the missing check), and is there a file on the medium that is not in the manifest (the added check)? A missing file shows up quickly as an install failure, but an added file passes without anyone knowing. When a report comes from the destination that "it won't install", before getting the media again (a week of review), first work out what is broken: the rpm, the table of contents, the definition, or the key.

Steps

  1. Create the /root/airgap/rpms directory and download tree and nano into that directory with all their dependencies (including those already installed).
  2. Create /root/airgap/MANIFEST.tsv. The first line is the header NAME EPOCH VERSION RELEASE ARCH SHA256 FILE (tab-separated), and you must fill in those values one line per rpm. Fill in 0 for a package with no epoch.
  3. Bundle the rpms directory and the manifest into /root/airgap/bundle.tar.gz, and save that archive's sha256 to /root/airgap/bundle.sha256.
  4. Unpack the archive into /root/airgap/unpacked/, and save the result of comparing the manifest's checksums against the actual files to /root/airgap/verify.txt. And write the number of files that are in the directory but not in the manifest as a single numeric line in /root/airgap/extra.txt (it must be 0).
  5. Build repository metadata in /root/airgap/unpacked/rpms and write /etc/yum.repos.d/airgap.repo. The repository ID is airgap-local; put the word snapshot and a date in the name, point the address at /root/airgap/unpacked/rpms with the file scheme, keep it enabled, turn off signature checking, and set metadata expiry to "never expires (-1)".
  6. With all other repositories turned off and only airgap-local on, reinstall tree, and save the output to /root/airgap/install.txt.
  7. Leave state records. Save the module list to /root/airgap/state-modules.txt and only what the user installed directly (excluding what came along as dependencies) to /root/airgap/state-userinstalled.txt.
  8. Incident: raise incident rh-bundle-broken, work out per import why three import repositories fail, and install each package from its repository. The report is /root/incident/rh-bundle-broken/report.txt.

Notes

Collecting the import bundle

Create the /root/airgap/rpms directory and download tree and nano into that directory with all their dependencies (including those already installed).

Direction: here you cannot know what is installed on the import target server; you must fetch not "what this machine lacks" but "everything needed" so that no dependency errors occur on the other side. Tools: the subcommand that fetches only files without installing, the option that fetches dependencies too, and the option that fetches even what is already installed. Concretely: after fetching, check whether base packages already installed, such as glibc, are also in the directory.

Generating the manifest

Create /root/airgap/MANIFEST.tsv. The first line is the header NAME EPOCH VERSION RELEASE ARCH SHA256 FILE (tab-separated), and you must fill in those values one line per rpm. Fill in 0 for a package with no epoch.

Direction: the manifest is the approved list by which people review what was put on the media and which is compared at the destination. Tools: the output format of the query mode for file paths (tags and conditional notation), a hash tool, a loop. Concretely: if there is no epoch, the query gives (none); fill in 0 with the conditional notation inside the format. The separator must be a tab.

Packing into an archive

Bundle the rpms directory and the manifest into /root/airgap/bundle.tar.gz, and save that archive's sha256 to /root/airgap/bundle.sha256.

Direction: put it on the media as a single lump so that the manifest and the rpms never get out of step. The hash of the archive itself (damaged in transit) is a different layer from the hashes of the rpms inside (is it the approved file). Tools: a compressed archive and a hash tool. Concretely: if you include absolute paths, you cannot choose where to unpack; include relative paths from the parent directory, and if you rebundle, regenerate the hash too.

Unpack and verify

Unpack the archive into /root/airgap/unpacked/, and save the result of comparing the manifest's checksums against the actual files to /root/airgap/verify.txt. And write the number of files that are in the directory but not in the manifest as a single numeric line in /root/airgap/extra.txt (it must be 0).

Direction: verification is two-way: are all the manifest's files there with the same hashes (missing, tampered), and have files not in the manifest been mixed in (extra). Extra files do not show up as install failures, so they are more dangerous. Tools: unpacking, a hash tool, the difference of two sorted lists. Concretely: empty the unpack location first so that leftovers from last time do not get mixed in.

Configuring the repository

Build repository metadata in /root/airgap/unpacked/rpms and write /etc/yum.repos.d/airgap.repo. The repository ID is airgap-local; put the word snapshot and a date in the name, point the address at /root/airgap/unpacked/rpms with the file scheme, keep it enabled, turn off signature checking (an unsigned snapshot of our own), and set metadata expiry to "never expires (-1)".

Direction: promote the imported pile of rpms to a repository. You may import the metadata together from outside, but then if even one file changes inside, the table of contents and the actual files disagree (one branch of the step 8 incident). Tools: the metadata generation tool, the .repo file. Concretely: on an air-gapped network, if expiry is active, the client goes out to refresh, finds nowhere to go, and fails. The key names and format are in the format example.

Installing from that repository alone

With all other repositories turned off and only airgap-local on, reinstall tree, and save the output to /root/airgap/install.txt.

Direction: if even one other repository is enabled, it does not prove "it works on an air-gapped network too". Tools: the pair of command-line options that turns off all repositories and turns on just one for this run only, the fetch-again subcommand. Concretely: airgap-local must remain in the Repository column of the output. dnf records which repository it installed from, so you can also confirm it later with a query.

Recording the module state

Leave state records. Save the module list to /root/airgap/state-modules.txt, and save only the packages the user installed directly (excluding those that came along as dependencies) to /root/airgap/state-userinstalled.txt. Saving the full installed list is a failure.

Direction: the import record also keeps "what state this machine was in at the time". A list excluding what came along as dependencies shows intent, and when rebuilding, that list is all you need; the resolver pulls in the rest again. Tools: the module list subcommand, the repository query option that picks only what the user installed. Concretely: this environment has no active modules, so the first file may be empty. It must contain tree from step 6 and must not contain dependent packages such as createrepo_c-libs.

Incident: since registering three import repositories, dnf cannot install anything

Running incident rh-bundle-broken registers three import media (bundle-a, bundle-b, bundle-c, under /srv/airgap-in) as repositories, and from then on dnf ends with errors (read the ticket first). Classify each import as one of baseurl-typo (the repository address is wrong), gpg-key-missing (the key file for signature verification is not on the media), metadata-expired (the metadata has expired), repodata-mismatch (the checksums in the table of contents differ from the metadata files), or rpm-corrupt (the rpm file itself is broken), and install dos2unix, telnet, and words from the repositories bundle-a, bundle-b, and bundle-c respectively. The three repositories must stay enabled (with the addresses pointing at the import media as they are), bundle-c must be installed with signature checking on (gpgcheck=1), turning off the check at install time with an option such as --nogpgcheck is not allowed either, and you must not change the rpms on the media or the approved list. In /root/incident/rh-bundle-broken/report.txt, write three lines <반입분>: <코드> (import: code) and evidence: <관찰한 출력 한 줄> (one line of output you observed).

Direction: even the same "install failure" differs in what dnf could not open: the table of contents (repomd.xml), a metadata file the table of contents points to, or the signing key file. And you cannot conclude "the media is broken" before comparing the rpm hashes with the approved list. Tools: install attempts with only one import enabled at a time, comparing the manifest with sha256, the checksums in repomd.xml versus the sha256 of the actual files, checking rpm signatures (key ID), and the distribution public keys already on this server (/etc/pki/rpm-gpg). Concretely: if Curl error (37) appears twice, look at which path each one failed to open. The metadata can be regenerated inside the media, but turning off signature checking is not a fix.