Thursday 3 November 2022

How to Configure Local YUM repository on CentOS 8 using Installation ISO Image



YUM (YellowDog Updater Modified) is a package management tool for RPM based Linux system that helps to install, uninstall, and update packages local and other client machines over the network. YUM resolve all dependency and install the package with all dependencies. CentOS 8 has two repositories BaseOS and AppStream and they are different from each other. BaseOS repository provides packages which are useful for an operating system and AppStream provides software packages such as databases and dependencies. 
This article describes How to Configure Local YUM repository on CentOS 8 using Installation ISO Image.
 
Step 1. Mount ISO Image on a Local Directory: Run the following commands to create a directory and to mount the CentOS8 ISO Image:
 
[root@linuxcnf ~]# mkdir -p /opt/localrepo
[root@linuxcnf ~]#
[root@linuxcnf ~]# mount CentOS-8-x86_64-1905-dvd1.iso /opt/localrepo/
mount: /opt/localrepo: WARNING: device write-protected, mounted read-only.
[root@linuxcnf ~]#
 
Step 2. Copy Repository Config File: First move all existing repository configuration to the other location and now copy the media.repo file from the ISO image files to /etc/yum.repos.d/ directory with the following permission:
 
[root@linuxcnf ~]# mv /etc/yum.repos.d/*.repo /tmp/
[root@linuxcnf ~]#
[root@linuxcnf ~]# cp /opt/localrepo/media.repo /etc/yum.repos.d/local-centos8.repo
[root@linuxcnf ~]#
[root@linuxcnf ~]# chmod 644 /etc/yum.repos.d/local-centos8.repo                [root@linuxcnf ~]#
 
Step 3. Config Modification: Run the following commands to edit the local CentOS 8 repo configuration file as below for BaseOS repo and AppStream repository:
 
[root@linuxcnf ~]# vi /etc/yum.repos.d/local-centos8.repo
[LocalRepo-BaseOS]
name=Local CentOS 8 Repo - BaseOS
gpgcheck=1
enabled=1
baseurl=file:///opt/localrepo/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
 
[LocalRepo-AppStream]
name=Local CentOS 8 Repo - AppStream
gpgcheck=1
enabled=1
baseurl=file:///opt/localrepo/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
 
Step 4. Repository Validation: Run the following commands to validate the local repository configuration:
 
Its good to clear the repository cache by running the below command before moving ahead:
 
[root@linuxcnf ~]# dnf clean all
18 files removed
[root@linuxcnf ~]#
 
Run the following command to check the configured repository list:
 
[root@linuxcnf ~]# dnf repolist
repo id                                                                       repo name
LocalRepo-AppStream                                                           Local CentOS 8 Repo - AppStream
LocalRepo-BaseOS                                                              Local CentOS 8 Repo - BaseOS
[root@linuxcnf ~]#
 
Now run the following package installation command to validate whether system is receiving packages from the local repository:
 
[root@linuxcnf ~]# dnf install ksh
Last metadata expiration check: 0:00:16 ago on Thu 03 Nov 2022 11:16:59 AM EDT.
……………………..
Installed:
  ksh-20120801-252.el8.x86_64
 
Complete!
[root@linuxcnf ~]#
 
Done!!! CentOS8 Local Repositories configured using installation ISO Image.

No comments:

Post a Comment