This guide walks you through setting up a local repository using an installation DVD or ISO file.
Creating an offline YUM repository allows you to manage and install packages on a RHEL 9 or Oracle Linux system without internet access.
Follow the steps:
- Insert the DVD 00or Mount the ISO
- For physical servers, insert the RHEL 9 installation DVD.
- For virtual machines, go to the VM’s settings, select Storage, and attach the RHEL ISO file.
- Mount the ISO File
Create a mount point and mount the DVD or ISO:mkdir -p /media/cdrom mount /dev/sr0 /media/cdrom
Alternatively, if using an ISO from disk:
mount -o loop rhel-9.2-x86_64-dvd.iso /media/cdrom/
Use df -h to confirm it’s mounted correctly.
- Configure the Local Repository:
- Copy the media.repo file from the mounted ISO:
cp /media/cdrom/media.repo /etc/yum.repos.d/
- Rename and set permissions:
mv /etc/yum.repos.d/media.repo /etc/yum.repos.d/redhat9.2.repo chmod 644 /etc/yum.repos.d/redhat9.2.repo
- Edit the repo file using vi or your preferred editor:
[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
- Copy the media.repo file from the mounted ISO:
- Clean the Yum/DNF Cache
Clear the metadata cache to ensure proper operation:dnf clean all
- Verify the Repository
Check if your system recognises the local repo:dnf repolist yum repolist
You should see both InstallMedia and InstallMedia-AppStream in the output.
- Install Packages Using Yum or DNF
Example: Install the make packageyum install make
If the installation proceeds without errors, your offline YUM repository is successfully configured.
Looking to enhance server security? Check out How to install ModSecurity on cPanel using command line