If you are working in an organization where you have lots of linux users and/or you have several computers to update via yum then you should consider creating a local repository. This will not even conserve bandwidth (updates are downloaded only once on the local reposotory) but it improves the speed of yum for installing additional programs as yum download the updates on the local LAN instead of the WAN. Just about anything that you do with yum is considerably faster (LAN vs. WAN). Although it have got one downside also that that you will probably download updates that are unnecessary for any of your machines. Even you can reduce this with additional “exclude” statements like “–exclude=*i18*” (see man rsync).
Following are the steps need to be followed to create a yum repository.

  1. Create the directory structure of the repository
  2. Copy the base RPMs
  3. Create the base repository headers
  4. Select an rsync mirror.
  5. Rsync the updates-released repository
  6. Creating a new repo entry

Before starting please install the createrepo package
# sudo yum -y install createrepo

Create the Directories:

  • mkdir /var/www/html/yum
  • mkdir /var/www/html/yum/base
  • mkdir /var/www/html/yum/updates

Copy the RPMs from the CDs/DVD to /var/www/html/yum/base if you have otherwise all the data will be downloaded from the internet which will take a lot of time.

Create the base repository headers:

# sudo createrepo /var/www/html/yum/base
This will going to take sometime depeding upon how much fast hardware you have. After successful completion, there should be a directory with name “repodata” inside base which will contain files like this:
“filelists.xml.gz, other.xml.gz, primary.xml.gz, repomd.xml”

Select a rsync mirror for updates:

The list of mirrors could be get from here – http://fedora.redhat.com/download/mirrors.html. All the mirrors share the common structure for updates. Simply append /updates/$version/$base-arch which will look like this:

Rsync to create the updates-released repository:

# rsync -av rsync://distro.ibiblio.org/fedora-linux-core/updates/4/i386 -exclude=debug/ /var/www/html/yum/upates

After completion there will be complete update repository at /var/www/html/yum/upates/i386. As you will need to run this rsync command from time to time so that you keep your repository updated with the new updates so make a cron job for this, which will rsync the data for you from time to time.

Creating a new repo entry on client:

  • Create a new file local.repo in /etc/yum.repos.d/ and put this content inside that:[base]
    name=Fedora Core $releasever – $basearch – Base

    name=Fedora Core $releasever – $basearch – Released Updates

If you enjoyed this post, make sure you subscribe to my RSS feed!!!!

No related content found.