How to Setup Local Yum/DNF Repository on CentOS 8 Server

Local YUM/DNF repository is the place where the rpm packages for Redhat or CentOS are stored and distributed to client servers for software installation and OS updates.
This local repository lets you save internet bandwidth as well as the time for downloading packages from the internet.
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.
[box type=”info” align=”” class=”” width=””]Related Read: Install CentOS 8 Minimal Server [/box]

1. Mount CentOS 8 ISO file / Installation DVD

To mount CentOS 8 ISO file inside your CentOS 8 server use the beneath mount command:

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

2. Create a CentOS 8 Local Yum Repository

In our case CentOS 8 Installation DVD or ISO file is mounted under /opt folder, use cp command to copy media.repo file to /etc/yum.repos.d/ directory

# cp -v /opt/media.repo  /etc/yum.repos.d/centos8.repo

Set “644” permission on “/etc/yum.repos.d/centos8.repo”

# chmod 644 /etc/yum.repos.d/centos8.repo
# ls -l /etc/yum.repos.d/centos8.repo

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

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

# nano 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.

3. Clean Yum / DNF and Subscription Manager Cache

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

4. Verify whether Yum / DNF is getting packages from Local Repo

Use dnf or yum repolist command to verify whether these commands are getting packages from Local repositories or not.

# dnf repolist
# yum repolist
repo id                 repo name                                         status
InstallMedia-AppStream  CentOS Linux 8 - AppStream            4,672
InstallMedia-BaseOS     CentOS Linux 8 - BaseOS               1,658

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

# nano /etc/yum/pluginconf.d/subscription-manager.conf

Save and exit the file.

5. Install Packages Using Local DNF or Yum Repository

Let’s assume we want to install nginx web server then run below dnf command:

# dnf install nginx
# yum instal nginx
dnf install nginx from local yum repository
dnf install nginx from local yum repository


That’s All. You have successfully configured the local yum repository on the machine.

Related Articles


  1. How to resolve this problem?

    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

  2. Hi there, is there a way to configure other local Centos 8 servers to point to this local repository server? If so what else would be needed?


Leave a Reply

Your email address will not be published. Required fields are marked *


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

Back to top button