Use CentOS ISO VPS image to build a local yum repository

Here to share the use of iso image to build a local yum warehouse simple steps:

Firs the preparatory work

Download or copy CentOS or RedHat iso image to the local, such as /usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso

Second, mount iso image

① new mount directory:

mkdir -p /mnt/cdrom1

② direct editing / etc / fstab file (please edit the backup please), add the following:

#Mount iso
/usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom1 iso9660 loop,defaults 0 0

② the implementation of mount-a automatically detect and activate the mount, if not reported, the implementation of df-h can see the results.

Third, configure and refresh the yum warehouse

①, add yum configuration file:

Ps: completely offline, it is recommended to delete (remove) all online yum source: mv -f /etc/yum.repos.d/* / home /vim /etc/yum.repos.d/local.repo Paste the following, the third line said iso mount directory:

[local-yum]
name=Local Repository
baseurl=file:///mnt/cdrom1
enabled=1
gpgcheck=0

② refresh Check yum is effective:

yum clean all && yum list

If no error above, then the local yum warehouse built, you can use [yum install software name] to install the required software, without the need for networking.

Fourth, a number of iso image approach:

Ps: The following only say that there are differences.

① when mounted, there are a few iso mount a few, such as CentOS 6.4 has two iso:

#Create 2 mount directories
mkdir -p /mnt/cdrom{1,2}
#Mount iso
/usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom1 iso9660 loop,defaults 0 0
/usr/local/src/CentOS-6.4-x86_64-bin-DVD2.iso /mnt/cdrom2 iso9660 loop,defaults 0 0
#Activate the mount
mount -a

② edit yum configuration file, the path needs to be changed to a path, such as:

[local-yum]
name=Local Repository
baseurl=file:///mnt/
enabled=1
gpgcheck=0

③ create repo command to create a yum repository:

cd /mnt/
createrepo .