How to create local mirror of the latest update of RHEL repos

Red Hat provides an utility which named “reposync” that you can use to download the packages from RHN. Before start to download package your system must be registered to RHN and system should be subscribed to that channel that you want to install repo packages. If you don’t have any subscribe it’s not possible to download packages from RHN. You should have at least one subscribe to create a local repos and share it for other servers.

For this purpose there is a solution which named “Satellite”.  But you need to take license for Satellite.  It’s not a free platform.  At this  post  I ‘ll show  you  how to  download a Repository  packages  to local  and share  it for other  systems.


  • How to register your server to RHN?
  • How to use reposync?
  • How to download RHN package for specific repo-id?
  • How to create a local repo with Red Hat updated packages?
  • How to share it for other Red Hat systems which is not connected and not registered to RHN?


  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5
  • Red Hat Network (RHN)
  • reposync

Let’s Start:

Step 1: First register Red Hat  Server to RHN

You should install and configure one server which’ll directly connect to RHN and registered to Red Hat repository. This is the server which you ‘ll use to download  packages  and share it  over  HTTP for other linux servers. So before start operation be sure your server has internet access over proxy or directly to connected internet.

After server installation check proxy configuration from rhn up2date  file which is located under “/etc/sysconfig/rhn/up2date”

# cat /etc/sysconfig/rhn/up2date|grep httpProxy
httpProxy[comment]=HTTP proxy in host:port format, e.g.

If your proxy server needs to an authentication so add your username and password to “up2date” file.

# cat /etc/sysconfig/rhn/up2date|egrep    'Passw|User'
proxyPassword[comment]=The password to use for an authenticated proxy
proxyUser[comment]=The username for an authenticated proxy

Step 2: Run  rhn_register

After define proxy information then you should register your server to Red Hat. First run “rhn_register” and follow to instructions from the link which I added below.

RHN Register Link From Red Hat Platform

If you don’t have a GUI access, don’t worry about this. Connect over SSH and run command then use “arrow, space and enter” to pass between screens.

You should have a RHN username and password which is subscribed the repository which you need to download.

There is another way to run only one command set to register server.

rhn_register --nox --proxy=<PROXYSERVERIP>:<PORT>


# rhnreg_ks --proxy=<PROXYSERVERIP>:<PORT>  --username=<RHN or Satellite login> --password=<RHN or Satellite password> --force

And also you can use this command to register server and assign an available subscribe. This command will register server and attach any available subscribe with this server.

# subscription-manager register --username <username> --password <password> --auto-attach

You can check available subscription with  this  command.
#subscription-manager list --available --all

Attach any  available subscribe which is  suitable with this system.
# subscription-manager attach --auto

Check This  Link  for  more  details  about Subscribtion.

Check  if server  gets  a subscribe  properly.

# subscription-manager list
Installed Product Status
Product Name:   Red Hat Enterprise Linux Server
Product ID:     69
Version:        6.5
Arch:           x86_64
Status:         Subscribed
Status Details:
Starts:         03/09/2015
Ends:           03/09/2018

Step 3: Create A repository area

Check if you have 50GB free area for only one repository. For example; in my case I’ll download RHEL6-Server repository. I used  “xampp” for sharing repository over  HTTP. But you don’t  need to install “xampp” . You can  create a  directory  which  named “/var/www/html/rhnrepo”. It’s  easy way  to  add  this  folder under  httpd.conf  and  restart  HTTPD service. I’ll explain  how to do it  at  next  steps.

# df -h /opt/lampp/htdocs/rhnrepo
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vgrepo-lvrepo   59G   30G   27G  53% /opt/lampp/htdocs/rhnrepo

Also don’t forget to import RPM key.

#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Step 4: Start  to download

Now you can start to download packages from RHN. First check your repository ID and also  install yum-utils, createrepo.

#yum install yum-utils createrepo

Repo-ID: rhel-x86_64-server-6

# yum repolist
Loaded plugins: product-id, rhnplugin, security, subscription-manager
This system is receiving updates from Red Hat Subscription Management.
This system is receiving updates from RHN Classic or RHN Satellite.
repo id                                                                                          repo name                                                                                                                            status
dvd-source                                                                                       RHEL 6.5 dvd repo                                                                                                                    16,506
rhel-x86_64-server-6                                                                             Red Hat Enterprise Linux Server (v. 6 for 64-bit x86_64)                                                                             16,506
repolist: 33,012

# reposync –gpgcheck -l –repoid=Repo-ID –download_path=/download/path

Example: Don’t forget  to change  download  directory  as you wish. This  command ‘ll  take 15-20  hours depends on your  network bandwith.

# reposync --gpgcheck -l --repoid=rhel-x86_64-server-6 --download_path=/opt/lampp/htdocs/rhnrepo

After  It  finishes then create  a  repository with  “createrepo” command

#createrepo -v /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/getPackage/

Step 5:Update and  Create repo with  metadata

Use “reposync”  command to download comps and  metadata. This to option’ll allow  to use variety  options like  yum-security and  groupinstall.

#reposync --gpgcheck -l --repoid=rhel-x86_64-server-6 --download_path=/opt/lampp/htdocs/rhnrepo --downloadcomps --download-metadata

After  it finishes then re-run “createrepo” command with  comps.xml

# cd /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6

# createrepo -v /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/ -g  /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/comps.xml

Step 6:HTTP configuration and Updateinfo.xml  files

If you pass  all steps  you are  ready to share  your  local repository to other  system. First  you need to share repository directory over HTTP.

You should edit  httpd.conf  file  which  is  located under “/etc/httpd/conf/”. If  your repository  directory  installed  under /var/www/html/rhnrepo then  add or edit  your configuration files  like this ;

<Directory /var/www/html/rhnrepo >

Order allow,deny

Allow from all


Restart  HTTPD  services;

#service httpd restart

Use any explorer to check if everything works fine.


Now  everything  is fine . Last step we’ll  share  updateinfo.xml file with clients  . So they can check  security  updates  with this  updateinfo.xml. Otherwise  they can’t  check  if  there  is a updated package. This  file  ‘ll be used  by client.

Redirect  under  repository download  directory.


#cd /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/

Take backup.

#cp  59a8bc1ddec36f240f691f8a3da9633e9db70d93bb83-updateinfo.xml.gz  /root/

#cd /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/

Extract updateinfo  file  under  repodata.

#gunzip -c 59a8bc1ddec36f2db5cf36c2b84864fc6a440f691f8a3da9633e9db70d93bb83-updateinfo.xml.gz  >> /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/updateinfo.xml

Remove updateinfo.xml.gz

#rm  -rf /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/59a8bc1ddec36f2db5cf36c2b84864fc6a440f691f8a3da9633e9db70d93bb83-updateinfo.xml.gz

Last  step run  modifyrepo.


# modifyrepo /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/updateinfo.xml /opt/lampp/htdocs/rhnrepo/rhel-x86_64-server-6/repodata/

Step 7: Create  yum.repos  file on client side


# cat /etc/yum.repos.d/server.repo







I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me