Guides‎ > ‎Other‎ > ‎YUM‎ > ‎CentOS‎ > ‎

5 - Repositories

There are two repositories I'm creating here:
  • i386
    • For 32bit CentOS
  • x86_64
    • For 64bit CentOS


Initial Notes

It's assumed that you already have downloaded the ISO file for CentOS that you used to install it on your computers. You'll need access to this ISO file in these steps, its contents will get copied into the "os" directory on the YUM server. You'll need both of the DVD1 and DVD2 iso files.

There are also three other parts to the repository that need to be downloaded as well, "updates", "extras" and "centosplus". The download steps below do this using the rsync command.

This guide is based on CentOS 5.11. You will probably be following this guide sometime in the future, and it's likely that a 5.12 version will be released. You'll need to change the steps below to reflect these correct locations, with the name of the ISO and in the rsync download locations. This is because once the updated version is released, the previous version will stop being available.

There are some steps below that create symbolic links, the purpose of doing this is explained on the Client Configuration page.


Common Steps

  • Establish an ssh session to your local YUM server
  • Type yum install -y rsync yum-utils wget and press Enter
  • Wait while the components are installed
  • Type mkdir -p /data/www/yumrpms/centos/5/5.11/updates and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/5.11/extras and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/5.11/centosplus and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/production/os and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/production/updates and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/production/extras and press Enter
  • Type mkdir -p /data/www/yumrpms/centos/5/production/centosplus and press Enter
  • Type mkdir -p /data/yumcomps and press Enter
  • Type chown -R apache:apache /data/www/yumrpms/centos/5/5.11/ and press Enter

i386

  • Type mkdir -p /data/www/yumrpms/centos/5/5.11/os/i386 and press Enter
  • You will now need to copy the CentOS-5.11-i386-bin-DVD-1of2.iso and CentOS-5.11-i386-bin-DVD-2of2.iso files to the /tmp/ directory of your YUM server. Once you've done that, continue.
  • Type mkdir /mnt/cdrom and press Enter
  • Type umount /mnt/cdrom and press Enter
  • Type mount -o loop /tmp/CentOS-5.11-i386-bin-DVD-1of2.iso /mnt/cdrom and press Enter
  • Type rsync -avh /mnt/cdrom/* /data/www/yumrpms/centos/5/5.11/os/i386/ and press Enter
  • Wait while the rpms are copied, this might take a while
  • Type umount /mnt/cdrom and press Enter
  • Type mount -o loop /tmp/CentOS-5.11-i386-bin-DVD-2of2.iso /mnt/cdrom and press Enter
  • Type rsync -avh /mnt/cdrom/* /data/www/yumrpms/centos/5/5.11/os/i386/ and press Enter
  • Type umount /mnt/cdrom and press Enter
  • We don't need the ISO files anymore, so we'll delete them
  • Type rm -f /tmp/CentOS-5.11-i386-bin-DVD*.iso and press Enter


  • The following commands will download the other repositories explained above. Due to the size of the download it can saturate your internet connection, hence alter the following argument in the command to tune it to your internet connection speed:
    •  --bwlimit=3096
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/centos/5.11/updates/i386 /data/www/yumrpms/centos/5/5.11/updates/ and press Enter
  • Wait while the rpms are downloaded, this might take a while
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/centos/5.11/extras/i386 /data/www/yumrpms/centos/5/5.11/extras/ and press Enter
  • Wait while the rpms are downloaded, this might take a while
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/centos/5.11/centosplus/i386 /data/www/yumrpms/centos/5/5.11/centosplus/ and press Enter
  • Wait while the rpms are downloaded, this might take a while


  • These commands create the repository data
    • These commands might take a while to complete as it has to process all the files
  • Type cp /data/www/yumrpms/centos/5/5.11/os/i386/repodata/comps.xml /data/yumcomps/comps-5.11-i386.xml and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/os/i386/ and press Enter
  • Type createrepo -d -s sha1 -g /data/yumcomps/comps-5.11-i386.xml /data/www/yumrpms/centos/5/5.11/os/i386/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/updates/i386/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/extras/i386/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/centosplus/i386/ and press Enter
  • Type chown -R apache:apache /data/www/yumrpms/centos/5/5.11/ and press Enter


  • These commands create the symbolic links
  • Type ln -s /data/www/yumrpms/centos/5/5.11/os/i386 /data/www/yumrpms/centos/5/production/os/i386 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/updates/i386 /data/www/yumrpms/centos/5/production/updates/i386 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/extras/i386 /data/www/yumrpms/centos/5/production/extras/i386 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/centosplus/i386 /data/www/yumrpms/centos/5/production/centosplus/i386 and press Enter


This completes the creation of the repository.


x86_64

  • Type mkdir -p /data/www/yumrpms/centos/5/5.11/os/x86_64 and press Enter
  • You will now need to copy the CentOS-5.11-x86_64-bin-DVD-1of2.iso and CentOS-5.11-x86_64-bin-DVD-2of2.iso files to the /tmp/ directory of your YUM server. Once you've done that, continue.
  • Type mkdir /mnt/cdrom and press Enter
  • Type umount /mnt/cdrom and press Enter
  • Type mount -o loop /tmp/CentOS-5.11-x86_64-bin-DVD-1of2.iso /mnt/cdrom and press Enter
  • Type rsync -avh /mnt/cdrom/* /data/www/yumrpms/centos/5/5.11/os/x86_64/ and press Enter
  • Wait while the rpms are copied, this might take a while
  • Type umount /mnt/cdrom and press Enter
  • Type mount -o loop /tmp/CentOS-5.11-x86_64-bin-DVD-2of2.iso /mnt/cdrom and press Enter
  • Type rsync -avh /mnt/cdrom/* /data/www/yumrpms/centos/5/5.11/os/x86_64/ and press Enter
  • Type umount /mnt/cdrom and press Enter
  • We don't need the ISO files anymore, so we'll delete them
  • Type rm -f /tmp/CentOS-5.11-x86_64-bin-DVD*.iso and press Enter


  • The following commands will download the other repositories explained above. Due to the size of the download it can saturate your internet connection, hence alter the following argument in the command to tune it to your internet connection speed:
    •  --bwlimit=3096
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/centos/5.11/updates/x86_64 /data/www/yumrpms/centos/5/5.11/updates/ and press Enter
  • Wait while the rpms are downloaded, this might take a while
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/5.11/centos/extras/x86_64 /data/www/yumrpms/centos/5/5.11/extras/ and press Enter
  • Wait while the rpms are downloaded, this might take a while
  • Type /usr/bin/rsync -avHh --exclude=repodata --delete --delete-after --bwlimit=1024 rsync://mirror.internode.on.net/centos/5.11/centosplus/x86_64 /data/www/yumrpms/centos/5/5.11/centosplus/ and press Enter
  • Wait while the rpms are downloaded, this might take a while


  • These commands create the repository data
    • These commands might take a while to complete as it has to process all the files
  • Type cp /data/www/yumrpms/centos/5/5.11/os/x86_64/repodata/comps.xml /data/yumcomps/comps-5.11-x86_64.xml and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/os/x86_64/ and press Enter
  • Type createrepo -d -s sha1 -g /data/yumcomps/comps-5.11-x86_64.xml /data/www/yumrpms/centos/5/5.11/os/x86_64/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/updates/x86_64/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/extras/x86_64/ and press Enter
  • Type createrepo -d -s sha1 /data/www/yumrpms/centos/5/5.11/centosplus/x86_64/ and press Enter
  • Type chown -R apache:apache /data/www/yumrpms/centos/5/5.11/ and press Enter


  • These commands create the symbolic links
  • Type ln -s /data/www/yumrpms/centos/5/5.11/os/x86_64 /data/www/yumrpms/centos/5/production/os/x86_64 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/updates/x86_64 /data/www/yumrpms/centos/5/production/updates/x86_64 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/extras/x86_64 /data/www/yumrpms/centos/5/production/extras/x86_64 and press Enter
  • Type ln -s /data/www/yumrpms/centos/5/5.11/centosplus/x86_64 /data/www/yumrpms/centos/5/production/centosplus/x86_64 and press Enter


This completes the creation of the repository.


Client Configuration

Please refer to the steps on this page on how to point your other machines to use the internal repositories.


Additional Information

The rsync commands above can be re-run again at any time to update the repositories.

Then re-run the createrepo command with --update, for example:

createrepo /data/www/yumrpms/centos/5/5.11/updates/x86_64/ --update

You could setup a cron job to perform these commands daily/weekly/monthly if so desired.

The rsync commands above use an Australian based mirror, you might want to locate a mirror closer to you.