How to Create Local Yum/DNF Repository on RHEL 9

Hello techies, recently Red Hat has released its latest operating system RHEL 9. RHEL 9 fulfill all the requirements of hybrid cloud. It can be installed on physical server, virtual machine and inside the container image.

When we don’t have subscription and want to install packages for doing the POCs then setting up local yum or dnf repository will be handy.

In this guide, we will cover how to create local yum/dnf repository on RHEL 9 using DVD or ISO file step by step.

Prerequisites for creating local Yum/DNF repository

  • Minimal Install RHEL 9 system
  • Sudo User with admin privileges
  •  RHEL 9 DVD or ISO file

1 ) Mount RHEL 9 ISO File or DVD

We are assuming RHEL 9 iso file is already copied into the system. Run following mount command to mount ISO file on /opt/repo folder.

$ sudo mkdir /var/repo
$ sudo mount -o loop rhel-baseos-9.0-x86_64-dvd.iso /var/repo/


In case of  dvd, run

$ sudo mount /dev/sr0 /var/repo/

2) Create Repo File in ‘/etc/yum.repos.d/’ Directory

Create a repo file with name ‘rhel9-local.repo’ under the folder /etc/yum.repos.d/ with following content

$ sudo vi /etc/yum.repos.d/rhel9-local.repo
name=Red Hat Enterprise Linux 9 - BaseOS

name=Red Hat Enterprise Linux 9 - AppStream

Save and close the file.


3) Flush Yum/DNF & Subscription Manager Cache

Execute following commands to clean yum or dnf and subscription manager cache.

$ sudo dnf clean all
$ sudo subscription-manager clean


In the above output, we are getting a warning message ‘This system is not registered with an entitlement’. So, to suppress this warning message, edit the file  ‘/etc/yum/pluginconf.d/subscription-manager.conf’ , change the parameter ‘enabled=1’ to ‘enabled=0’.

$ sudo vi /etc/yum/pluginconf.d/subscription-manager.conf


Save and exit the file.

4) Install Packages using Local Repository

Now we are all set to test our local repository. Run beneath command to view configure repository.

$ sudo dnf repolist



Now, try Install packages using dnf command via above configure local repository.

$ sudo dnf install nfs-utils




Perfect, above output confirms that nfs-utils package along with its dependencies are installed successfully via locally configured yum or dnf repository.

That’s all from this guide. I hope you have found it informative. Kindly do post your queries and feedback in below comments section.

Also Read: How to Install PostgreSQL 15 on RHEL 9 Step by Step

Share on:

I am a Cloud Consultant with over 15 years of experience in Linux, Kubernetes, cloud technologies (AWS, Azure, OpenStack), automation (Ansible, Terraform), and DevOps. I hold certifications like RHCA, CKA, CKAD, CKS, AWS, and Azure.

6 thoughts on “How to Create Local Yum/DNF Repository on RHEL 9”

  1. please how did you do this first step

    “We are assuming RHEL 9 iso file is already copied into the system. Run following mount command to mount ISO file on /opt/repo folder.”

  2. In step 1, mounting the iso, you state in the written step port to mount it to /opt/repo. However in your example and display snip, you have it as /var/repo. May be a bit confusing to some.

  3. 🙁 it didn’t work for me. After turned enable=0 on /etc/yum/pluginconf.d/subscription-manager.conf. Run sudo dnf repolist and install… All repos were removed.

    # sudo dnf clean all
    Updating Subscription Management repositories.
    17 files removed
    # sudo subscription-manager clean
    All local data removed
    # sudo vi /etc/yum/pluginconf.d/subscription-manager.conf
    # sudo dnf repolist
    No repositories available
    # sudo dnf install nfs-utils
    Error: There are no enabled repositories in “/etc/yum.repos.d”, “/etc/yum/repos.d”, “/etc/distro.repos.d”.
    When I checked back to the redht.repo. It’s empty file.


Leave a Comment