How to create local YUM repository

It is always very handy to set up your own local repository to prevent from downloading the remote repository over and over again. This tutorial shows how to create a CentOS mirror for your local network. If you have to install couple of or multiple systems in your local network then all needed packages can be downloaded over the fast LAN connection, thus saving your internet bandwidth and your valuable time.

Create the Directories:

    mkdir -pv /var/www/html/centos/5/{base,updates}/i386

You can repleace 5 and i386 with your major version and architecture. If you want to build multiple repositories for different architecture then create more directories. e.g for x86_64 create seperate directory.

Copy rpms to created directories :
Download a latest iso or which ever centos version you want to create repository for.
mount it on your system with following command as root user.

    [mycentos]#mount -o loop centos-image.iso /tmp
    cp /tmp/CentOS/*.rpm /var/www/html/centos/5/base/i386/.

Create the base repository headers:

createrepo /var/www/html/centos/5/base

Now create a updates repository :

/usr/bin/rsync -avrt rsync://rsync.mirrorservice.org/mirror.centos.org/5.2/updates/i386 /var/www/html/centos/5/updates/

Back to top