How to setup local yum repository on CentOS 8 or RHEL 8 server using DVD or ISO File?

In various technical forum, I’ve seen a request of procedure for setting up local yum repository on CentOS 8 or RHEL 8 server using DVD or ISO files. This article is created for documenting that process.

If you don’t know how to configure AWS SSM for patching or if you have limitation of implementing automation, this local yum repository will help you to maintain same package version across PROD and non-PROD environment.

Let’s start to understand the process..

Step:1 Mount CentOS 8/RHEL 8 ISO file

Execute the sample command like below

mount -o loop centos8.iso /opt/

Note: I’m assuming that you have already copied Centos 8 or RHEL 8 ISO file inside your system.

In case you have installation DVD, then you need to mount it.

Sample command is shown below:

mount /dev/sr0 /opt

Step:2 Copy media.repo file from the mounted directory to /etc/yum.repos.d/

You can refer below sample command:

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

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

Replace xxx8.repo with yours. It could be Centos or RHEL based on your need.

Sample command has been mentioned below for your reference:

chmod 644 /etc/yum.repos.d/centos8.repo

Step:3 Add repository entries in “/etc/yum.repos.d/centos8.repo” file

name=CentOS Linux 8 - BaseOS

name=CentOS Linux 8 - AppStream


Make sure you replace Centos with RHEL in case if you are working with RHEL. Other parameters will remain same.

Step:4 Clear the dnf OR yum cache

yum clean all


dnf clean all

Step:5 Verify that the system will get packages from the locally defined repositories:

yum repolist


dnf repolist

To Suppress warning message that you will receive from RHEL while forking above commands, you may want to disable subscription manager in the file “/etc/yum/pluginconf.d/subscription-manager.conf”

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



You are now done.

You can now install packages using the usual commands like

yum install apache


dnf install apache