Wednesday, 12 January 2022

How to Configure Local YUM repository on CentOS 7 using 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.
This article describes How to Configure Local YUM repository on CentOS 7 using ISO Image.
Step 1. Mount ISO and Copy ISO Contents to Local Directory: Run the following commands to mount and copy ISO content into local directory to access the RPM packages by YUM:
[root@linuxcnf ~]# mount -t iso9660 /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@linuxcnf ~]#
[root@linuxcnf ~]# mkdir /opt/localrepo
[root@linuxcnf ~]#
Now run the following command to copy the ISO contents into /opt/localrepo directory:
[root@linuxcnf ~]# cp -rv /mnt/* /opt/localrepo/
‘/mnt/CentOS_BuildTag’ -> ‘/opt/localrepo/CentOS_BuildTag’
‘/mnt/EFI’ -> ‘/opt/localrepo/EFI’
‘/mnt/EFI/BOOT’ -> ‘/opt/localrepo/EFI/BOOT’
‘/mnt/RPM-GPG-KEY-CentOS-Testing-7’ -> ‘/opt/localrepo/RPM-GPG-KEY-CentOS-Testing-7’
‘/mnt/TRANS.TBL’ -> ‘/opt/localrepo/TRANS.TBL’
[root@linuxcnf ~]#
Step 2. Configure the Local Repository: Run the following commands to move the old repo configuration file to other location as a backup:
[root@linuxcnf ~]# cd /etc/yum.repos.d/
[root@linuxcnf yum.repos.d]# mv * /root/
Create a local.repo named file under /etc/yum.repos.d/ and put the below contents in the file:
[root@linuxcnf yum.repos.d]# vi local.repo
name=Local YUM Repository
Step 3. Update Repository: Run the following commands to update local repository and create meta data:
[root@linuxcnf yum.repos.d]# createrepo /opt/localrepo/
Spawning worker 0 with 445 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@linuxcnf yum.repos.d]#
Step 4. Validate the Repository: Run the following command to clean up and validate the repository:
[root@linuxcnf ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: CentOS7-Local
Cleaning up list of fastest mirrors
Other repos take up 120 M of disk space (use --verbose for details)
[root@linuxcnf ~]#
[root@linuxcnf ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
CentOS7-Local                                            | 2.9 kB     00:00
CentOS7-Local/primary_db                                   | 797 kB   00:00
repo id                          repo name                                status
CentOS7-Local                    Local YUM Repository                     445
repolist: 445
[root@linuxcnf ~]#
Done!!! Local yum Repositories is configured on CentOS 7.

No comments:

Post a Comment