Configuring DVD/ISO Repositories in Rocky Linux 8 for Offline Use

Configuring DVD/ISO Repositories in Rocky Linux 8 for Offline Use

Overview

To ensure the successful deployment and operation of the Swarm software platform, it is essential to install several prerequisite packages at the operating system level. These dependencies—such as libraries, utilities, and runtime environments—are not included with the Swarm application but are managed via the system's package manager (dnf, formarly yum).

In typical scenarios, Rocky Linux 8 retrieves these packages from online repositories. However, in offline or air-gapped environments, users must configure the system to use the official Rocky Linux 8 installation media (DVD or ISO file) as a local source of packages. This guide outlines the process for mounting the installation media, disabling the default internet-based repositories, and configuring dnf to utilize these local media repositories.

Prerequisites

  • Rocky Linux 8 Installation Media: Either the official DVD or a corresponding ISO file (e.g., Rocky-8.x-x86_64-dvd1.iso)

  • Administrative Access: root or sudo privileges are required to modify system configurations and mount devices

Procedure

Step 1: Mount the Installation Media

The Rocky Linux 8 installation media must be mounted to the system’s file system to access its contents.

Option A: Utilizing a Physical DVD

  1. Insert the Rocky Linux 8 DVD into the system's optical drive.

  2. The media may be automatically mounted, typically under:

    /run/media/<username>/<DVD_Label>/
  3. If not automatically mounted, use the following commands:

    sudo mkdir -p /mnt/dvd sudo mount /dev/sr0 /mnt/dvd

    (Replace /dev/sr0 with the appropriate device, which can be confirmed using lsblk.)

  4. Confirm the contents:

    ls /mnt/dvd

    You should see directories such as BaseOS, AppStream, and EFI.

Option B: Utilizing an ISO File

  1. Ensure the ISO file is present on the target system's filesystem (e.g., transferred via external media). For example, the location is /path/to/Rocky-8.x-x86_64-dvd1.iso.

  2. Create a mount point directory:

    sudo mkdir -p /mnt/iso
  3. The ISO file is mounted using the loop device:

    sudo mount -o loop /path/to/Rocky-8.x-x86_64-dvd1.iso /mnt/iso

    (Replace /path/to/Rocky-8.x-x86_64-dvd1.iso with the actual file path)

  4. List the contents:

    ls /mnt/iso

Directories such as BaseOS, AppStream, and EFI should be visible.

For the remainder of this guide, /mnt/media will represent the generic mount point. Substitute /mnt/media with /mnt/dvd or /mnt/iso based on your chosen method.

Step 2: Disabling Default Online Repositories

To ensure dnf uses only the local media, disable the standard repository configuration files pointing to online sources. A safe approach is to move these files to a designated backup location.

  1. Change the current directory to the repository configuration location:

    cd /etc/yum.repos.d/
  2. Create a directory for storing the disabled repository files:

    sudo mkdir disabled_repos
  3. Move the default Rocky Linux .repo files into the newly created backup directory.

    sudo mv Rocky*.repo disabled_repos/

Adjustments may be needed in the above command if other custom .repo files are disabled.

Caution

Ensure no essential third-party repository files are moved unless a fully offline environment is intended.

This file contains:

  • Rocky-AppStream.repo

  • Rocky-BaseOS.repo

  • Rocky-Extras.repo

  • Rocky-Debuginfo.repo (if present)

  • Rocky-Devel.repo (if present)

  • Rocky-NFV.repo (if present)

  • Rocky-Plus.repo (if present)

  • Rocky-PowerTools.repo (or Rocky-CRB.repo in later 8.x versions)

Step 3: Creating a Local Repository Configuration File

A new .repo file is needed to define the local media as a package source for dnf.

  1. Create and open a new file named local-media.repo using a text editor:

    sudo nano /etc/yum.repos.d/local-media.repo
  2. Insert the following configuration into the file.
    Ensure /mnt/media is replaced with the actual mount point /mnt/dvd or /mnt/iso.

    [Local-BaseOS] name=Rocky Linux 8 BaseOS - Local Media baseurl=file:///mnt/media/BaseOS enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial [Local-AppStream] name=Rocky Linux 8 AppStream - Local Media baseurl=file:///mnt/media/AppStream enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

     

    1. [Local-BaseOS], [Local-AppStream]: Unique identifiers for these repository definitions.

    2. name: Descriptive names for the repositories.

    3. baseurl: Specifies the location of the package repositories (BaseOS and AppStream directories) on the mounted media via the file:// protocol.

    4. enabled=1: Marks the repositories as active.

    5. gpgcheck=1: Enforces GPG signature verification for packages.

    6. gpgkey: Specifies the path to the Rocky Linux GPG public key file, used for signature verification. This key is typically installed during system setup and is also available on the installation media.

  3. Save and close the text editor (in nano, press Ctrl+X, then Y, then Enter). 

Step 4: Verify the Configuration

  1. Clear the dnf cache to remove outdated repository information:

    sudo dnf clean all
  2. List the currently enabled repositories. The output should show only the Local-BaseOS and Local-AppStream repositories defined in the previous step:

    sudo dnf repolist

    The expected output will resemble:

    repo id               repo name                                status Local-AppStream       Rocky Linux 8 AppStream - Local Media    #,### Local-BaseOS          Rocky Linux 8 BaseOS - Local Media       #,###

    (The numerical values (# and # # #) indicate the number of packages found in each repository.)

  3. Test the package installation. For example, installing the tree package:

    sudo dnf install tree

    The dnf should successfully locate the tree package within the configured local repositories and proceed with installation without attempting network access.

Step 4: Revert to Online Repositories

To switch back to the online repositories:

  1. Remove or disable the local media repository file:

    sudo rm /etc/yum.repos.d/local-media.repo

    Or, edit the file and set enabled=0 for both repository sections.

  2. Restore the original repository files:

    sudo mv /etc/yum.repos.d/disabled_repos/Rocky*.repo /etc/yum.repos.d/ sudo rmdir /etc/yum.repos.d/disabled_repos
  3. Clean the dnf cache and refresh the repository list:

    sudo dnf clean all sudo dnf repolist
  4. Unmount the installation media if no longer needed:

    sudo umount /mnt/media

Substitute /mnt/dvd or /mnt/iso as appropriate.

Following these steps configures a Rocky Linux 8 system to utilize its installation media as a package source, enabling package management functionalities in offline scenarios.