How to configure yum / dnf repo in RHEL 8 server with screenshots and Bonus Tip

 
DNF or YUM configuration
 
 

In this article, you how to configure yum or dnf in RHEL 8. There are two repositories that have been added one for AppStream and the second is BaseOS. In RHEL 8 both app and base os repositories have been separated from each other.
In RHEL 8 default package manager is dnf and it is symlink with yum.
We will configure yum from the local iso but the procedure is the same from the FTP server too only need to change the baseurl path.

What is yum or dnf

If we want to install any package in Linux we can simply install it with the rpm command. But what will happen if the rpm package has dependencies and dependencies also have a dependency. This means for one package installation we have to install 5 other packages and those 5 packages have other 10 packages. If we use yum or dnf dependency part has been handled by these package managers. We have to just confirm that we want to install dependency with the required package.

Till RHEL 7 yum is the main package manager and in RHEL 8 REDHAT had introduced dnf as a package manager.

Difference Between YUM and DNF

There is some basic difference between yum and dnf.

  • yum is written in only python while dnf in c,c++, and python
  • dnf consume less memory than yum.
  • If any repo is not available yum stop working but dnf skip that repo which is not available
  • The main difference in RHEL 8 dnf or yum is they have separated BaseOS and APPStream which was in the same repo in RHEL 7.
  • If you are a coder the dnf has half code of lines than yum.

These are some basic differences between yum and dnf. There are many more differences but this is a different topic.

How to configure yum(Yellow Dog Update Modifier) or dnf(Dandified Yum) in RHEL 8

1.Mount RHEL 8 DVD or iso to OS

Mount DVD by DVD reader.If you are using ESXi mount from local datastore in settings and In hypervisor mount from local drive.

2. Check mounted devices

  # lsblk

check%2Bmounted%2Biso dnf
           here it is sr0

 

In your case it may be different, you can verify with a new device added or with the size of the disk.
 
     3. Mount iso to /mnt or any other directory. We have mounted here on /mnt
        # mount -o loop /dev/sr0 /mnt
 
 
mount%2B o%2Bloop dnf
As you can see it is mounted on /mnt and this is read-only mode mounted.
 
 
   4. Create a rhel8.repo file in yum directory
       # vi /etc/yum.repos.d/rhel8.repo
 
Make sure there is no entry in this file. If you have any other entry then you can create any new girl with .repo extension.
 
  5. Make below entry in file make sure do add space or special charector in bracket:
 
[AppStream]
name=Appstream
baseurl=file:///mnt/AppStream/
enable=1
gpgcheck=0
 
[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS/
enable=1
gpgcheck=0
 
6. Press esc, type-   :wq! enter  to save file
RHEL8.repo dnf
 
 
7. You can replace ftp server link also on baseurl = http://siteaddrss/AppStream . If you are using FTP server.
 
8. Check it is correctly configured or not from the below command.
# yum repolist
#dnf repolist
 
yum%2Brepolist dnf
 
Now you have configured yum and you can start to install packages from yum/dnf.

Bonus Tip :

First Tip:

If you are working in a test environment and dnf is configured more than once or any other issue cause error in repolist or packaged installation. 

Run below command :

# rm -r /var/cache/dnf 

This will remove old cache and then run repolist and install packages. 

Second Tip:

Besides using a mounted DVD you can create a directory for yum or dnf and copy /mnt files to the created folder. This will reduce the risk of DVD unmount or corruption. If all packaged are at local installation will be faster.

Do not confuse if we are using repository in local then why not installed all packaged in OS installation time. For new users keep packaged local, only take your HDD space but install all package will consume CPU and RAM which reduce system or server performance.

 

 

Leave a Comment

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