How to Set Up a Local Yum/DNF Repository on CentOS 8

In this article, you will learn how you can locally set up a DNF or YUM repository on your CentOS 8 system using an ISO or an installation DVD.

CentOS 8 ships with 2 repositories: BaseOS and AppStream (Application Stream) – So what’s the difference between the two repositories?

The BaseOS repository consists of the requisite packages required for the existence of a minimal operating system. On the other hand, AppStream comprises the remaining software packages, dependencies, and databases.

Related Read: How to Create Local HTTP Yum/DNF Repository on RHEL 8

Now let’s roll up our sleeves and set up a local YUM/DNF repository in CentOS 8.

Step 1: Mount CentOS 8 DVD Installation ISO File

Begin by mounting the ISO file to a directory of your choice. Here, we have mounted in on /opt directory.

# mount CentOS-8-x86_64-1905-dvd1.iso /opt
# cd /opt
# ls
Mount CentOS 8 ISO File
Mount CentOS 8 ISO File

Step 2: Create a CentOS 8 Local Yum Repository

In the mounted directory where your ISO is mounted, copy the media.repo file to the /etc/yum.repos.d/ directory as shown.

# cp -v /opt/media.repo  /etc/yum.repos.d/centos8.repo
Create CentOS 8 Local Yum Repository
Create CentOS 8 Local Yum Repository

Next, assign file permissions as shown to prevent modification or alteration by other users.

# chmod 644 /etc/yum.repos.d/centos8.repo
# ls -l /etc/yum.repos.d/centos8.repo
Set Permission On Yum Repository File
Set Permission On Yum Repository File

We need to configure the default repository file residing on the system. To check the configurations, use the cat command as shown.

# cat etc/yum.repos.d/centos8.repo
Check Yum Repository File
Check Yum Repository File

We need to modify the configuration lines using a text editor of your choice.

# vim etc/yum.repos.d/centos8.repo

Delete all the configuration, and copy & paste the configuration below.

name=CentOS Linux 8 - BaseOS

name=CentOS Linux 8 - AppStream

Save the repo file and exit the editor.

After modifying the repository file with new entries, proceed and clear the DNF / YUM cache as shown.

# dnf clean all
# yum clean all

To confirm that the system will get packages from the locally defined repositories, run the command:

# dnf repolist
# yum repolist
List Yum Repositories
List Yum Repositories

Now set ‘enabled’ parameter from 1 to 0 in CentOS-AppStream.repo and CentOS-Base.repo files.

Step 3: Install Packages Using Local DNF or Yum Repository

Now, let’s give it a try and install any package. In this example, we are going to install NodeJS on the system.

# dnf install nodejs
# yum install nodejs
Install Packages from Local Yum Repository
Install Packages from Local Yum Repository

And this is a clear indicator that we have successfully set up a local DNF/YUM repository on CentOS 8.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

14 thoughts on “How to Set Up a Local Yum/DNF Repository on CentOS 8”

  1. Hi There, I need help here. I’m trying to set up a Local Yum/DNF Repository on Rhel 8 and this is the first step that has to be performed – mount CentOS-8-x86_64-1905-dvd1.iso to /opt. However, I am unable to find the iso details mentioned here, For Example – “CentOS-8-x86_64-1905-dvd1.iso”.

    Can someone please help me to find from where can I get these details?

  2. After I have successfully created my repository and installed some software I will reboot and then either my system will boot the disk that is connected or I disconnect the disk it won’t boot and put me in some safe mode. What am I doing wrong?

  3. Followed the steps and tried installing nodejs at the end. Eneded up seeing this error:

    [[email protected] yum.repos.d]# yum install nodejs
    Warning: failed loading ‘/etc/yum.repos.d/mongodb-org-4.4.repo’, skipping.
    CentOS-8 – AppStream 13 MB/s | 6.3 MB 00:00
    CentOS-8 – Base 12 MB/s | 2.3 MB 00:00
    CentOS-8 – Extras 82 kB/s | 8.6 kB 00:00
    CentOS Linux 8 – BaseOS 0.0 B/s | 0 B 00:00
    Errors during downloading metadata for repository ‘InstallMedia-BaseOS’:
    – Curl error (37): Couldn’t read a file:// file for file:///opt/BaseOS/repodata/repomd.xml [Couldn’t open file /opt/BaseOS/repodata/repomd.xml]
    Error: Failed to download metadata for repo ‘InstallMedia-BaseOS’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    [[email protected] yum.repos.d]#

  4. Hi, great article but in our case, it’s missing the last few steps. I want this local server to act as a repo server for all other Centos 8 servers on my network. How can I enable that? Thanks

  5. I have this problem, please help me…

    CentOS-8 – AppStream 0.0 B / s | 0 B 00:30
    Metadata for “AppStream” repository failed to load
    Error: Failed to load metadata for “AppStream” repository

  6. I have the same problem as Robert. I’m working with a system that has NO internet access. I only have access to the DVD media (running on Qemu behind a corporate firewall. DHCP not working). Previously on some versions of CentOS, I could run a yum install command with:

    yum --disablerepo=\* --enablerepo=c8-media install mysql

    But this doesn’t work on Centos 8 and I don’t know why.

    • The solution (for CentOS 8) is to look at the file /etc/yum.repos.d/CentOS-Media.repo.

      First, mount the DVD. I used /media/CentOS.

      As documented in the file use:

      yum --disablerepo=\* --enablerepo=c8-media-BaseOS (or) c8-media-AppStream

      Previously c5-media, c6-media, etc would work.

  7. Thanks for the post.

    Unfortunately I get an error message for the command.

    # yum repolist

    Error: Failed to download metadata for repo ‘AppStream’. I have no idea what to do about this. The AppStream and BaseOS directories are located at /mnt/usb/ on a usbstick

  8. Won’t “Now set ‘enabled’ parameter from 1 to 0 in CentOS-AppStream.repo and CentOS-Base.repo files disable repositories” disable created repos and install command will ignore them?


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.