Using Official Redhat DVD as repository

Introduction

If your Redhat server is not connected to the official RHN repositories, you will need to configure your own private repository which you can later use to install packages. The procedure of creating a Redhat repository is quite simple task. In this article we will show you how to create a local file Redhat repository as well as remote HTTP repository.

Using Official Redhat DVD as repository

After default installation and without registering your server to official RHN repositories your are left without any chance to install new packages from redhat repository as your repository list will show 0 entries:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0

At this point the easiest thing to do is to attach your Redhat installation DVD as a local repository. To do that, first make sure that your RHEL DVD is mounted:

# mount | grep iso9660
/dev/sr0 on /media/RHEL_6.4 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=500,gid=500,iocharset=utf8,mode=0400,dmode=0500)

The directory which most interests us at the moment is "/media/RHEL_6.4 x86_64 Disc 1/repodata" as this is the directory which contains information about all packages found on this particular DVD disc.

Next we need to define our new repository pointing to "/media/RHEL_6.4 x86_64 Disc 1/" by creating a repository entry in /etc/yum.repos.d/. Create a new file called: /etc/yum.repos.d/RHEL_6.4_Disc.repo using vi editor and insert a following text:

[RHEL_6.4_Disc]
name=RHEL_6.4_x86_64_Disc
baseurl="file:///media/RHEL_6.4 x86_64 Disc 1/"
gpgcheck=0

Once file was created your local Redhat DVD repository should be ready to use:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
RHEL_6.4_Disc RHEL_6.4_x86_64_Disc 3,648
repolist: 3,648


Creating a local file Redhat repository

Normally having a Redhat DVD repository will be enough to get you started however, the only disadvantage is that you are not able to alter your repository in any way and thus not able to insert new/updated packages into it. The resolve this issue we can create a local file repository sitting somewhere on the filesystem. To aid us with this plan we will use a createrepo utility.

By default createrepo may not be installed on your system:

# yum list installed | grep createrepo
#

No output indicates that this packages is currently not present in your system. If you have followed a previous section on how to attach RHEL official DVD as your system's repository, then to install createrepo package simply execute:

# yum install createrepo

The above command will install createrepo utility along with all prerequisites. In case that you do not have your repository defined yet, you can install createrepo manually:

Using your mounted RedHat DVD first install prerequisites:

# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/deltarpm-*
# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/python-deltarpm-*

followed by the installation of the actual createrepo package:

# rpm -hiv /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/createrepo-*

If all went well you should be able to see createrepo package installed in your system:

# yum list installed | grep createrepo
createrepo.noarch                        0.9.9-17.el6                          installed

At this stage we are ready to create our own Redhat local file repository. Create a new directory called /rhel_repo:

# mkdir /rhel_repo

Next, copy all packages from your mounted RHEL DVD to your new directory:

# cp /media/RHEL_6.4\ x86_64\ Disc\ 1/Packages/* /rhel_repo/

When copy is finished execute createrepo command with a single argument which is your new local repository directory name:

# createrepo /rhel_repo/
Spawning worker 0 with 3648 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

As a last step we will create a new yum repository entry:

# vi /etc/yum.repos.d/rhel_repo.repo
[rhel_repo]
name=RHEL_6.4_x86_64_Local
baseurl="file:///rhel_repo/"
gpgcheck=0

Your new repository should now be accessible:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel_repo | 2.9 kB 00:00 ...
rhel_repo/primary_db | 367 kB 00:00 ...
repo id repo name status
RHEL_6.4_Disc RHEL_6.4_x86_64_Disc 3,648
rhel_repo RHEL_6.4_x86_64_Local 3,648

Creating a remote HTTP Redhat repository

If you have multiple Redhat servers you may want to create a single Redhat repository accessible by all other servers on the network. For this you will need apache web server. Detailed installation and configuration of Apache web server is beyond the scope of this guide therefore, we assume that your httpd daemon ( Apache webserver ) is already configured. In order to make your new repository accessible via http configure your apache with /rhel_repo/ directory created in previous section as document root directory or simply copy entire directory to: /var/www/html/ ( default document root ).

Then create a new yum repository entry on your client system by creating a new repo configuration file:

vi /etc/yum.repos.d/rhel_http_repo.repo

with a following content, where my host is a IP address or hostname of your Redhat repository server:

[rhel_repo_http]
name=RHEL_6.4_x86_64_HTTP
baseurl="http://myhost/rhel_repo/"
gpgcheck=0

Confirm the correctness of your new repository by:

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
rhel_repo_http RHEL_6.4_x86_64_HTTP 3,648
repolist: 3,648

Conclusion

Creating your own package repository gives you more options on how to manage packages on your Redhat system even without paid RHN subscription. When using a remote HTTP Redhat repository you may also want to configure GPGCHECK as part of your repository to make sure that no packages had been tampered to prior their installation.

 

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
RHEL: Reinstalling Boot Loader on the Master Boot Record (MBR)
Viewed 2940 times since Sun, May 27, 2018
Configuring VLAN interfaces in Linux
Viewed 4894 times since Mon, May 21, 2018
Tcpdump Examples Linux
Viewed 5554 times since Fri, Nov 16, 2018
LVM: Reduce SWAP size by removing a Logical Volume
Viewed 1713 times since Sat, Jun 2, 2018
YUM CRON RHEL7: Configure automatic updates.
Viewed 1675 times since Fri, Oct 26, 2018
Using IOzone for Linux disk performance analysis
Viewed 7106 times since Wed, Jul 25, 2018
How to use yum command on CentOS/RHEL
Viewed 10349 times since Wed, Oct 17, 2018
ZPOOL: Remove an existing zpool
Viewed 1891 times since Sun, Jun 3, 2018
Script to Offline and Remove A Disk In Linux
Viewed 1689 times since Mon, Jan 28, 2019
Check Detailed CPU Information In Linux With CoreFreq [Advanced]
Viewed 1999 times since Thu, Apr 18, 2019