How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File

Recently Red Hat has released its most awaited operating system “RHEL 8“, in case you have installed RHEL 8 Server on your system and wondering how to setup local yum or dnf repository using installation DVD or ISO file then refer below steps and procedure.

Setup-Local-Repo-RHEL8

In RHEL 8, we have two package repositories:

  • BaseOS
  • Application Stream

BaseOS repository have all underlying OS packages where as Application Stream repository have all application related packages, developer tools and databases etc. Using Application stream repository, we can have multiple of versions of same application and Database.

Step:1) Mount RHEL 8 ISO file / Installation DVD

To mount RHEL 8 ISO file inside your RHEL 8 server use the beneath mount command,

[root@linuxtechi-rhel8 ~]# mount -o loop rhel-8.0-x86_64-dvd.iso /opt/

Note: I am assuming you have already copied RHEL 8 ISO file inside your system,

In case you have RHEL 8 installation DVD, then use below mount command to mount it,

[root@linuxtechi-rhel8 ~]# mount /dev/sr0  /opt

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

In our case RHEL 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,

[root@linuxtechi-rhel8 ~]# cp -v /opt/media.repo /etc/yum.repos.d/rhel8.repo
'/opt/media.repo' -> '/etc/yum.repos.d/rhel8.repo'
[root@linuxtechi-rhel8 ~]#

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

[root@linuxtechi-rhel8 ~]# chmod 644 /etc/yum.repos.d/rhel8.repo
[root@linuxtechi-rhel8 ~]#

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

By default, rhel8.repo file will have following content,

default-rhel8-repo-file

Edit rhel8.repo file and add the following contents,

[root@linuxtechi-rhel8 ~]# vi /etc/yum.repos.d/rhel8.repo
[InstallMedia-BaseOS]
name=Red Hat Enterprise Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///opt/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///opt/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

rhel8.repo should look like above once we add the content, In case you have mounted the Installation DVD or ISO on different folder then change the location and folder name in base url line for both repositories and rest of parameter leave as it is.

Step:4) Clean Yum / DNF and Subscription Manager Cache 

Use the following command to clear yum or dnf and subscription manager cache,

root@linuxtechi-rhel8 ~]# dnf clean all
[root@linuxtechi-rhel8 ~]# subscription-manager clean
All local data removed
[root@linuxtechi-rhel8 ~]#

Step:5) 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.

[root@linuxtechi-rhel8 ~]# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1:32:44 ago on Sat 11 May 2019 08:48:24 AM BST.
repo id                 repo name                                         status
InstallMedia-AppStream  Red Hat Enterprise Linux 8 - AppStream            4,672
InstallMedia-BaseOS     Red Hat Enterprise Linux 8 - BaseOS               1,658
[root@linuxtechi-rhel8 ~]#

Note : You can use either dnf or yum command, if you use yum command then its request is redirecting to DNF itself because in RHEL 8 yum is based on DNF command.

If you have noticed the above command output carefully, we are getting warning message “This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register”, if you want to suppress or prevent this message while running dnf / yum command then edit the file “/etc/yum/pluginconf.d/subscription-manager.conf”, changed the parameter “enabled=1” to “enabled=0”

[root@linuxtechi-rhel8 ~]# vi /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0

save and exit the file.

Step:6) Installing packages using DNF / Yum

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

[root@linuxtechi-rhel8 ~]# dnf install nginx

dnf install nginx rhel8

Similarly if you want to install LEMP stack on your RHEL 8 system use the following dnf command,

[root@linuxtechi-rhel8 ~]# dnf install nginx mariadb php -y

LEMP Stack Install RHEL8

This confirms that we have successfully configured Local yum / dnf repository on our RHEL 8 server using Installation DVD or ISO file.

In case these steps help you technically, please do share your feedback and comments.

Read More on : How to Install and Configure KVM on RHEL 8

Share Now!

9 thoughts on “How to Setup Local Yum/DNF Repository on RHEL 8 Server Using DVD or ISO File”

  1. Your post here is very complete from .iso or DVD. We only used pieces since this wasn’t our task, but the pieces were very helpful. We had installed the latest Oracle database with unsupported product versions, and we had used two Oracle Linux repos to get the pieces we needed. After the installation one was disabled, the other left active, and it was causing problem that even Google had never recorded. No hits on the errors, not even on a Russian site. Your post here put the whole process into focus so we could fix our problem.

    Thank you.

    Reply
  2. Hi,
    I recently failed in RHCSA 8 exam, one of the questions I could’t figure out was the repo.
    here is my story, the URL to the repo was given. for example lets say ‘http://baserepo.com/baseos’
    This is what I did:
    vi /etc/yum.repos.d/baseos.repo
    [baseos]
    name=Base OS RHEL 8
    baseurl=http://baserepo.com/baseos
    enabled=1

    once I saved the file, I ran this ” yum clean all”. when I used “yum repolist” both repositories I configured were listing as normal.
    however when I used ” yum install vdo” nothing happened. I was given an error message I can’t remember. any idea what could be the issue?

    Thank you for your time.

    Reply
    • Hi Jimmy,

      First i will check whether i can reach to repository on 80 port and also check whether required network settings are configured or not. I would also recommend use dnf command instead of yum.

      Reply
  3. I got this error. This process works before RHEL 8.

    [root@PXE2 yum.repos.d]# yum repolist
    repo id repo name
    InstallMedia-AppStream Red Hat Enterprise Linux 8.2.0 – AppStream
    InstallMedia-BaseOS Red Hat Enterprise Linux 8.2.0 – BaseOS

    [root@PXE2 yum.repos.d]# yum list
    Red Hat Enterprise Linux 8.2.0 – BaseOS 0.0 B/s | 0 B 00:00
    Error: Failed to download metadata for repo ‘InstallMedia-BaseOS’: repomd.xml parser error: Parse error at line: 1 (Extra content at the end of the document
    )

    Reply
  4. Hi Folks

    Quick question here when I tried to run the command “yum repolist” the output was repo id and repo name details and not the status count, as shown below:-

    repo id repo name
    InstallMedia-AppStream Red Hat Enterprise Linux 8 – AppStream
    InstallMedia-BaseOS Red Hat Enterprise Linux 8 – BaseOS

    Reply

Leave a Comment