Setup Local Mirror of RHEL Repo

How To create your own local Red Hat Enterprise Linux yum repository server

To begin, build a virutal machine or stand alone system installing the same OS version of Red Hat you wish to serve as the yum repository. At the time of this writing, my base OS plus mirror data consumed 14G of disk space so be sure to size your disk appropriately. This is necessary as you must register the mirror server to a RHN Satellite, which allows the system to receive software updates. It’s also important to know that one physical system cannot subscribe to multiple architecture base channels. In otherwords, if you install a 64-bit OS, you cannot subscribe to the 32-bit channel.

After the system has been deployed, you’re ready to begin:

Register with RHN

~# rhn_register -vv --nox

Install required packaged

~# yum install createrepo
~# yum install yum-utils

Create a directory for the repo and sync the base channel

~# mkdir /opt/rhel6repo
~# reposync --gpgcheck -l --repoid=rhel-x86_64-server-6 --download_path=/opt/rhel6repo

!!! note
This will take a long time to run. I ran mine overnight

Create repo data

~# createrepo /opt/rhel6repo

Configure apache to serve the content

~# cat /etc/httpd/conf.d/rhel-6-repo.conf
Alias /rhel-6-repo /opt/rhel6repo

<Directory /opt/repository>
Options Indexes MultiViews FollowSymLinks
Order allow,deny
Allow from all
</Directory>

Start/restart apache

~# service httpd start

Configure the clients

Add the repo to the yum config:

~# cat /etc/yum.repos.d/rhel6.repo
[rhel-6-repo]
name=My Red Hat Enterprise Linux $releasever - $basearch
baseurl=http://<IP_ADDRESS>/rhel-6-repo
enabled=1
gpgcheck=0

From the client, verify it can see the mirror with:

yum repolist

!!! info
You can disable connectivity to Red Hat network by changing the value of enabled = 0 in the file /etc/yum/pluginconf.d/rhnplugin.conf

Clean out the yum cache and remove old header info on the client.

~# yum clean all

Now, you can list all of the updates available from your local mirror.

~# yum list updates

Share