Using local repositories with yum

One of the great advantages of Red Hat Enterprise Linux is the fact that it uses yum & that it ties into the Red Hat Network. That said, the RHN is subscription-based, and sometimes you either don’t want to license a new VM (if you’re tight on numbers) or you simply don’t care about getting security notifications. Trouble is, with yum, if the machine doesn’t exist in RHN, you can’t use yum at all.

(I suppose you could cheat and use a CentOS repository in your RHEL box, but that would be naughty! I bet it would work though…)

So I figured I would just use a RHEL DVD and create a yum repository out of that. While it obviously won’t give you security updates, it will let you use yum to install packages and resolve dependencies. Note that this also works with an ISO image instead of a physical DVD; simply see the note underneath the first step.

Mount your RHEL DVD

mkdir /media/cdrom
mount /dev/cdrom /media/cdrom

(If you’re using an ISO and not a DVD, substitute the above mount command with mount -o loop /path/to/RHEL_DVD.iso /media/cdrom)

Install createrepo

rpm -ivh /media/cdrom/Packages/createrepo* /media/cdrom/Packages/deltarpm* /media/cdrom/Packages/python-deltarpm*

Create a local repository

mkdir /media/repo
createrepo -o /media/repo /media/cdrom

Configure yum to use the local repository

Create a file called /etc/yum.repos.d/local.repo and populate it thusly:

[local]
name=Local ISO repository
baseurl=file:///media/rhel
enabled=1
gpgcheck=0

If you’ve already installed the RPM GPG key, you won’t need that last line about gpgcheck.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s