Creating Local repo in CentOS by using ISO file

  1. copy the ISO file from DVD or other centos server by using SCP

#scp ISOfile (source file) 192.168.x.x(destination ip):/opt/package/(destination folder)

Eg:

#scp Centos-7_DVD.iso 192.168.x.x:/opt/isofile

  1. mount the iso file to directory

#mount –o loop isofile /dir

Eg:

#mount –o loop Centos-7_DVD.iso /mnt

  1. Create one new directory in “opt” directory to copy the rpm packages

#cd /opt

#mkdir /package

#cp /mnt/package/*.* /opt/package/

  1. Create repo in the directory /opt/package

# createrepo –v .

  1. Create local repo file in /etc/yum.repo.d/ directory

#cd /etc/yum.repo.d/

#vi local.repo

  1. Add the lines in that local.repo file

Eg:

[local]

name=local

baseurl=file:///opt/package

enabled=1

gpgcheck=0

name: user understandable name for localrepo

baseurl: path of local repo file directory

enabled: 0 means disabled and 1 means enabled

  1. Unmount the /mnt directory from system

#umount /mnt

  1. Enable the repo

#yum-config-manager –enable local

  1. Clean the cache and check the repo is enabled or not

#yum clean all

#yum repolist all

Leave a comment