Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks

Sunday, 23 November 2014

How To : Create a Local YUM Repository in Red Hat Enterprise Linux

    If you are having RHEL installed on your server and you wish to install new packages or update existing ones, creating local repository will be a good option. Setting up local YUM repositories will fetch the packages/updates from the local server, not only saving the bandwidth and hence the cost, but also the installation process will fasten up.

This tutorial will guide you to set up a local YUM repository on your RHEL/CentOS systems.

Step 1: Mount the DVD or ISO.

For DVD, you can run

$ mount /dev/cdrom /mnt
For ISO, you can run

$ mount -t iso9660 -o loop /path/to/iso/image /mnt
Step 2: Install the 'createrepo' package.

In order to install 'createrepo' package along with its dependencies, execute the following command:

$ cd /mnt && rpm -ivh libxml2-python* deltarpm* python-deltarpm* createrepo*
Step 3: Move the packages to a directory.

$ cp -ar /mnt/* /home/mandar/repos/rhel65/
Step 4: Build the local Repository

$ createrepo -v /home/mandar/repos/rhel65/
Step 5: Create the Repository File

$ vi /etc/yum.repos.d/rhel65.repo
In that file, add following lines:

name=RHEL 6.5
Step 6: Disable all other repositories and Update repository file

If there are any other repositories, then disable them by editing them as enabled=0.
Now, you can update the repository file as follows:

$ yum clean all && yum update
In order to list all available packages, you can run:

$ yum list
Now, you can try installing the packages normally using : yum install [PackageName].


Post a Comment