Setting up an offline YUM repository in Linux allows system administrators to install and manage packages without internet connectivity. This is especially useful in secure environments, data centers, or isolated networks where internet access is restricted.
In this guide, you'll learn how to configure an offline YUM/DNF repository using an ISO file or installation DVD on RHEL 9 and Oracle Linux.
Why Use an Offline YUM Repository?
An offline repository provides several benefits:
Install packages without internet access
Faster package installation within local networks
Increased security for restricted environments
Ideal for production servers and air-gapped systems
Step 1: Insert the DVD or Mount the ISO File
First, insert the RHEL 9 installation DVD or mount the ISO file on your server.
If you're using a virtual machine, go to:
VM Settings → Storage → Select the ISO file
Step 2: Mount the RHEL 9 ISO File / Installation DVD
Create a directory where the ISO will be mounted.
[root@dbdocs ~]# mkdir -p /media/cdrom
Now mount the DVD or ISO file.
[root@dbdocs ~]# mount /dev/sr0 /media/cdrom
Verify the mount using:
[root@dbdocs ~]# df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 890M 0 890M 0% /dev/shm
tmpfs 356M 5.7M 351M 2% /run
/dev/mapper/rhel-root 17G 7.0G 11G 41% /
/dev/sda1 1014M 292M 723M 29% /boot
tmpfs 178M 108K 178M 1% /run/user/1000
/dev/sr0 9.0G 9.0G 0 100% /media/cdrom
tmpfs 178M 36K 178M 1% /run/user/0
Alternative: Mount an ISO File from Disk
If the ISO file is stored on the system, use the loop option:
mount -o loop rhel-9.2-x86_64-dvd.iso /media/cdrom/
Step 3: Configure the Repository (.repo File)
Copy the repository configuration file from the mounted media.
[root@dbdocs yum.repos.d]# cp /media/cdrom/media.repo /etc/yum.repos.d/
Rename the file and adjust permissions.
[root@dbdocs yum.repos.d]# mv media.repo redhat9.2.repo
[root@dbdocs yum.repos.d]# chmod 644 redhat9.2.repo
Now edit the repository file.
[root@dbdocs yum.repos.d]# vi /etc/yum.repos.d/redhat9.2.repo
Add the following configuration:
[InstallMedia]
name=Red Hat Enterprise Linux 9.2.0
mediaid=None
metadata_expire=-1
gpgcheck=1
cost=500
enabled=1
baseurl=file:///media/cdrom/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 9.2.0 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/cdrom/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Save and exit the file.
Step 4: Clean Yum / DNF Cache
Clear the existing cache to ensure the system reads the new repository.
[root@dbdocs yum.repos.d]# dnf clean all
Example output:
8 files removed
Step 5: Verify the Repository Configuration
Check whether the system detects the repository.
[root@dbdocs yum.repos.d]# dnf repolist
Example output:
repo id repo name
InstallMedia Red Hat Enterprise Linux 9.2.0
InstallMedia-AppStream Red Hat Enterprise Linux 9.2.0 - AppStream
You can also verify using:
[root@dbdocs yum.repos.d]# yum repolist
Step 6: Install Packages Using the Offline Repository
Now test the repository by installing a package.
First check if the package exists:
[root@dbdocs yum.repos.d]# yum list installed make
If not installed, install it:
[root@dbdocs yum.repos.d]# yum install make
If the installation succeeds, it confirms that your offline YUM/DNF repository is working correctly.
Final Thoughts
Configuring an offline YUM repository in RHEL 9 or Oracle Linux is a practical solution for environments where internet access is limited or restricted. By mounting the installation media and configuring a local repository, you can efficiently manage packages without relying on external sources.
This method is commonly used in:
Enterprise servers
Secure environments
Data centers
Air-gapped networks
⭐ Stay Connected with Us
For more Linux tutorials, DevOps guides, and AI technology insights, visit:
https://genaiapec.com
Follow us for more guides on Linux Administration, Cloud, and AI Technologies.
