Translate

Image of Linux Kernel Development (3rd Edition)
Image of Operating System Concepts
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)
Image of Modern Operating Systems (3rd Edition)

Configure a Local ISO-based Package Repository on a CentOS 7.2 VM

Consider the following scenario. You have downloaded the CentOS-7-x86_64-Everything-1511.iso from the CentOS Project or a mirror, used the ISO to create a VM in VMware Workstation, and now want to be able to access a package repository (repo) when you have no Internet access. Assume that a GNOME desktop is available on your CentOS VM and the VM is sized such that you have at least 8 Gb of free disk space.

Copy the IS0 to your CentOS VM by whatever method works for you. If you have VMware Tools installed, you can just drag and drop the file using your mouse. Make a directory, say /var/centos-iso, and place the ISO in that directory. Make another directory, say /var/centos72, and mount the ISO on this directory as a read-only loop device as shown below:

As you can see from the above image, if the mount worked, you can then cd to /var/centos72 and the contents of the ISO are available to you in the usual Unix tree-like structure.

To access the packages on the ISO using yum or dnf, you need to disable your existing repos (remember enabled=0?) and add a new repo which points to /var/centos72. Here is an example of such a repo.

# cat /etc/yum.repos.d/dvd.repo
[dvd]
name=CentOS 7.2 1511 All 
baseurl=file:///var/centos72/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

To test if you have your repo definitions configured correctly, run yum -v repolist as shown below:

Only your newly created repo should be listed and you should see output similar to what is highlighted in the red box. By the way, it is also a good ides to run yum clear all first.

You can also use rpm to examine the contents of the packages in your repo using the -p option as shown below:

To persist access to your new repository after a reboot, you need to add a suitable entry to /etc/fstab. Here is an example of such an entry based on the mount command used earlier in this post:

/var/centos72-iso/CentOS-7-x86_64-Everything-1511.iso  /var/centos72  iso9660  loop,ro  0  0

Enjoy!

Leave a Reply