If you explore the contents of your CentOS/RHEL installation dvd you would find that it contains really big yum repos. You can identify a yum repo by any directory that contains a folder called repodata
If you have used an ISO file to install your OS, then that ISO file is simply the file equivalent of the installation DVD (for this article we will ignore DVDs and assume you have an ISO).
We can therefore configure our ISO/DVD to act as a local yum repo. To do this, you first need to mount the iso.
To mount the iso, we first create a mount point:
$ mkdir -p /data/iso
Then we mount the iso using the mount command:
$ mount -o loop /vagrant/CentOS-6.6-x86_64-minimal.iso /data/iso/ mount: /dev/loop0 is write-protected, mounting read-only
Note: we need to use the "loop" option when mounting an ISO or dvd.
We can then check this has worked using df:
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos_puppetmaster-root 38G 4.7G 33G 13% / devtmpfs 488M 0 488M 0% /dev tmpfs 497M 80K 497M 1% /dev/shm tmpfs 497M 7.0M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/sda1 497M 149M 349M 30% /boot none 224G 156G 68G 70% /vagrant /dev/loop0 383M 383M 0 100% /data/iso
or we can check using the mount command:
$ mount | grep '/data/iso' /vagrant/CentOS-6.6-x86_64-minimal.iso on /data/iso type iso9660 (ro,relatime)
Obviously another way to check is by going into the mount point itself, and see what's there:
$ ls -l /data/iso/ total 82 -r--r--r--. 1 root root 14 Oct 24 2014 CentOS_BuildTag dr-xr-xr-x. 3 root root 2048 Oct 24 2014 EFI -r--r--r--. 1 root root 212 Nov 27 2013 EULA -r--r--r--. 1 root root 18009 Nov 27 2013 GPL dr-xr-xr-x. 3 root root 2048 Oct 24 2014 images dr-xr-xr-x. 2 root root 2048 Oct 24 2014 isolinux dr-xr-xr-x. 2 root root 40960 Oct 24 2014 Packages -r--r--r--. 1 root root 1354 Oct 19 2014 RELEASE-NOTES-en-US.html dr-xr-xr-x. 2 root root 4096 Oct 24 2014 repodata -r--r--r--. 1 root root 1706 Nov 27 2013 RPM-GPG-KEY-CentOS-6 -r--r--r--. 1 root root 1730 Nov 27 2013 RPM-GPG-KEY-CentOS-Debug-6 -r--r--r--. 1 root root 1730 Nov 27 2013 RPM-GPG-KEY-CentOS-Security-6 -r--r--r--. 1 root root 1734 Nov 27 2013 RPM-GPG-KEY-CentOS-Testing-6 -r--r--r--. 1 root root 3380 Oct 24 2014 TRANS.TBL
Now to set up the local repo we can manually create the .repo file. Byt it is easier to just use the yum-config-manager command:
$ yum-config-manager --add-repo=file:///data/iso
Note the three forward slashes.
Now we can check this has worked by using yum repolist:
$ yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.clouvider.net * epel: fedora.cu.be * extras: mirrors.clouvider.net * updates: centos.muzzy.org.uk repo id repo name status base/7/x86_64 CentOS-7 - Base 8,652 data_iso added from: file:///data/iso 248 epel/x86_64 Extra Packages for Enterprise Linux 7 8,545 extras/7/x86_64 CentOS-7 - Extras 214 foreman/x86_64 Foreman 1.9 367 foreman-plugins/x86_64 Foreman plugins 1.9 216 puppetlabs-deps/x86_64 Puppet Labs Dependencies El 7 - x86_64 17 puppetlabs-products/x86_64 Puppet Labs Products El 7 - x86_64 191 rhscl-ruby193-epel-7-x86_64 Ruby193 - epel-7-x86_64 405 rhscl-v8314-epel-7-x86_64 V8 3.14.5.10 - epel-7-x86_64 21 updates/7/x86_64 CentOS-7 - Updates 1,501 repolist: 20,377
[post-content post_name=rhsca-quiz]
1. Create a mount point
2. mount the iso onto the mount point
3. create a repo file pointing to the new mount point
$ mount -o loop /tmp/library.iso /data/iso
It contains a folder called "repodata"
$ yum-config-manager --add-repo=file:///data/iso