In this short how-to guide, we are about to see how to create a local yum repository using RHEL 8 ISO. Like previous RHEL distributions if we plan to create a local yum repo it won’t work as expected. It may throw an error for dependencies while trying to install any packages. This may help someone who looking for how to create one in RHEL 8.

RedHat Enterprise Linux 8 comes with two repositories they are “BaseOS” packages and “AppStream” packages. In our below repository configuration, we have two repository information.

BaseOS Repository will contain packages like OS installation packages (Core Packages), Administrative tools packages and their dependencies. You can navigate to location /mnt/BaseOS/Packages to have a look.

AppStream Repository will have all remaining packages like vim, PostgreSQL, MariaDB, Maven, Bind, LibreOffice and all other application and OS related dependencies under /mnt/AppStream/Packages.

You may interested on RHEL 8 Related Articles.

Let us begin with creating a local Yum Repo.

Mounting ISO

In your case, if you need to mount the DVD-ROM or mounted ISO in your virtual machine follow the below steps. For demonstration purpose, we are mounting under /mnt.

# mount /dev/sr0 /mnt/
Mount and list the ISO content
Mount and list the ISO content

Creating Yum Repository file

Navigate to the usual repository file location and create a file in any name. In my case, I’m creating as local.repo.

# cd /etc/yum.repos.d/
# vi local.repo

Append with below entry into your created file.

[rhel8_BaseOS]
 name=rhel8_BaseOS
 baseurl=file:///mnt/BaseOS
 enabled=1
 gpgcheck=1
 gpgkey=file:///mnt/RPM-GPG-KEY-redhat-release

 [rhel8_AppStream]
 name=rhel8_AppStream
 baseurl=file:///mnt/AppStream
 enabled=1
 gpgcheck=1
 gpgkey=file:///mnt/RPM-GPG-KEY-redhat-release
Created yum repository content
Created yum repository content

Let’s see what are the above line means.

  • A name of Repository
  • BaseURL from which location the packages need to be downloaded.
  • Whether the Repo is enabled or not. 0 is Disabled, 1 is Enabled.
  • While installing a package whether it needs to check for GPG key.
  • Which key needs to be used to verify the packages.

We have locally mounted the ISO/DVD so the BaseURL should start as file:// by following mount point and path of Repository. The GPG key for RHEL 8 resides under the root (/) of the ISO file.

Read about how to use AppStream on RHEL 8.

Listing the Created Yum Repository

List the repository using yum or dnf.

30 Yum command for Package Management in Linux

# yum repolist all
# dnf repolist
Listing the created Yum repo in rhel 8
Listing the created Yum repo in rhel 8

Now it’s time to verify by installing anyone of packages.

# dnf install tcpdump -y
# yum install tcpdump -y

If the package installed without throwing any error we are good with configuring a local yum repository.

[root@rhel8 ~]# 
 [root@rhel8 ~]# dnf install tcpdump
 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: 0:05:57 ago on Thu 09 May 2019 07:33:22 PM IST.
 Dependencies resolved.
  Package                                 Arch                                   Version                                        Repository                                       Size
 Installing:
  tcpdump                                 x86_64                                 14:4.9.2-5.el8                                 rhel8_AppStream                                 477 k
 Transaction Summary
 Install  1 Package
 Total size: 477 k
 Installed size: 1.3 M
 Is this ok [y/N]: y
 Downloading Packages:
 warning: /mnt/AppStream/Packages/tcpdump-4.9.2-5.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
 rhel8_AppStream                                                                                                                                      2.9 MB/s | 5.0 kB     00:00    
 Importing GPG key 0xFD431D51:
  Userid     : "Red Hat, Inc. (release key 2) security@redhat.com"
  Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
  From       : /mnt/RPM-GPG-KEY-redhat-release
 Is this ok [y/N]: y
 Key imported successfully
 Importing GPG key 0xD4082792:
  Userid     : "Red Hat, Inc. (auxiliary key) security@redhat.com"
  Fingerprint: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792
  From       : /mnt/RPM-GPG-KEY-redhat-release
 Is this ok [y/N]: y
 Key imported successfully
 Running transaction check
 Transaction check succeeded.
 Running transaction test
 Transaction test succeeded.
 Running transaction
   Preparing        :                                                                                                                                                             1/1 
   Running scriptlet: tcpdump-14:4.9.2-5.el8.x86_64                                                                                                                               1/1 
   Installing       : tcpdump-14:4.9.2-5.el8.x86_64                                                                                                                               1/1 
   Running scriptlet: tcpdump-14:4.9.2-5.el8.x86_64                                                                                                                               1/1 
   Verifying        : tcpdump-14:4.9.2-5.el8.x86_64                                                                                                                               1/1 
 Installed products updated.
 Installed:
   tcpdump-14:4.9.2-5.el8.x86_64                                                                                                                                                      
 Complete!
 [root@rhel8 ~]# 

That’s it we have successfully created a Yum local repository in RedHat Enterprise Linux 8 Server.

Conclusion:

We have created an RHEL 8 local yum repository using ISO file. This will help for someone who looking to figure out how to install a few packages without a valid RHEL subscription. Let us come up with another article until subscribe to our newsletter to keep you updated.

Babin Lonston
Overall 13+ Years of experience in IT field, 7+ years of experience in Linux administration with Virtualization & Cloud technologies. Love documentation and being Numismatics for a long time.

Installing RedHat Enterprise Linux 8.0 with screenshots

Previous article

Generate a CSR Certificate Signing Request in Linux

Next article

You may also like

Comments

Leave a reply

Your email address will not be published.

More in Linux