Create local yum repository

When there’s need to have local yum repository, it can be created easily.

To create one, we need createrepo-package. And createrepo needs to prereq packages: deltarpm and python-deltarpm.

In my case, I downloaded RPMs (with dependencies) and copied them to Linux with no Internet access and used following commands to install createrepo and prereqs (newer versions may be available):

rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
rpm -ivh createrepo-0.9.9-22.el6.noarch.rpm

Now that we have createrepo, we can create new repository.

Execute createrepo in a directory that includes all RPMs that should be in the local repository.

createrepo /repo/rpmdir

And after the repository directory have been created, we need to add new repository configuration. To do that, create new file in /etc/yum.repo.d directory and name it like mylocalrepo.repo.

The contents of the file is similar to:

[mylocalrepo]
name=My Local Repository
baseurl="file:///repo/rpmdir/"
enabled=1
gpgcheck=0

Finally, check that your local repo is available using:

yum list

And start installing packages from local repository using yum.

Leave a Reply