How to Setup Local DNF Repository on RHEL 8 Server using ISO or DVD

0

Finally Red Hat released their best optimized operating system “RHEL 8“. They have changed many features and increased performances than the previous version of RHEL 7. So If you install RHEL 8 Server in your system, then you need to setup local yum or dnf repository. To do this you need to have installation DVD or ISO image file and need to follow the below steps and procedure.

If you have previous version RHEL-7 and need to setup yum repository, visit the below post:
How to setup local YUM Repository on RHEL 7

Local YUM or DNF repository is the place where the rpm packages for Redhat/CentOS are stored and distributed to client servers for software installation and OS updates.

In RHEL 8, there are two package repositories:
1. BaseOS
2. Application Stream (AppStream)

Packages in BaseOS is intended to provide the core set of the underlying OS functionality that provides the foundation for all type installations. 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.

Mount RHEL 8 installation DVD or ISO file:

To mount a DVD use below mount command
# mount /dev/sr0 /mnt
# cd /mnt
or if you already installed server from ISO image then you will find the mounted ISO image as below:
# df -h
/dev/sr0 7.2G 7.2G 0 100% /run/media/root/RHEL-8-1-0-BaseOS-x86_64

Copy the inside items of RHEL 8 DVD or ISO file into a local directory:

# mkdir /reposerver
# cd /run/media/root/RHEL-8-1-0-BaseOS-x86_64
# cp -pfrv * /reposerver

Remove or Backup existing repo file:
Remove/backup repo file existing in yum.repos.d directory
# cd /etc/yum.repos.d/
# rm -fr *
or
# mv /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.backup

Create a new repo file for YUM or DNF setup:

# vim /etc/yum.repos.d/rhel8.repo
[InstallMedia-BaseOS]
name=rhel-8-BaseOS
baseurl=file:///reposerver/BaseOS/
metadata_expire=-1
enabled=1
gpgcheck=0

[InstallMedia-AppStream]
name=rhel-8-AppStream
baseurl=file:///reposerver/AppStream/
metadata_expire=-1
enabled=1
gpgcheck=0

Clean Yum / DNF and Subscription Manager Cache:

# dnf clean all
# subscription-manager clean

Verify whether Yum / DNF is getting packages from Local Repo:
# dnf repolist all
Last metadata expiration check: 2:13:53 ago on Fri 08 Jan 2021 10:12:28 AM +06.
repo id repo name status
InstallMedia-AppStream rhel-8-AppStream enabled: 4,795
InstallMedia-BaseOS rhel-8-BaseOS enabled: 1,662

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.

Here, you will see a warning message like “This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register”

If you want to prevent this message while running dnf / yum command then edit the file subscription-manager.conf file and change the enabled value to 0.
# vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0

Install the packages using DNF / Yum:

# dnf install vsftpd
The output will be like below:

# dnf install vsftpd
Last metadata expiration check: 1:20:39 ago on Fri 08 Jan 2021 10:12:28 AM +06.

Dependencies resolved.

Package Architecture Version Repository Size

Installing:
vsftpd x86_64 3.0.3-28.el8 InstallMedia-AppStream 180 k

Transaction Summary

Install 1 Package

Total size: 180 k
Installed size: 356 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : vsftpd-3.0.3-28.el8.x86_64 1/1
Running scriptlet: vsftpd-3.0.3-28.el8.x86_64 1/1
Verifying : vsftpd-3.0.3-28.el8.x86_64 1/1
Installed products updated.

Installed:
vsftpd-3.0.3-28.el8.x86_64

Complete!

Conclusion:

Now you have successfully setup local yum repository on your RHEL 8 Server.