Skip to main content

Create a YUM Package Repository on Redhat/Centos

1. 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.
2. 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:


baseurl="file:///media/RHEL_6.4 x86_64 Disc 1/"

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
3. 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
You are also able to create Redhat repository on any debian-like Linux system such as Debian, Ubuntu or mint. The procedure is the same except that installation of createrepo utility will be: # apt-get install createrepo
As a last step we will create a new yum repository entry:
# vi /etc/yum.repos.d/rhel_repo.rep



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
4. 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:



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
5. 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.


Popular posts from this blog

CentOS / Redhat : Configure CentOS as a Software Router with two interfaces

Linux can be easily configured to share an internet connection using iptables. All you need to have is, two network interface cards as follows: a) Your internal (LAN) network connected via eth0 with static ip address b) Your external WAN) network is connected via eth1 with static ip address  ( public IP provided by ISP ) Please note that interface eth1 may have public IP address or IP assigned by ISP. eth1 may be connected to a dedicated DSL / ADSL / WAN / Cable router: Step # 1: Enable Packet Forwarding Login as the root user. Open /etc/sysctl.conf file # vi /etc/sysctl.conf Add the following line to enable packet forwarding for IPv4: net.ipv4.conf.default.forwarding=1 Save and close the file. Restart networking: # service network restart Step # 2: Enable IP masquerading In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceivin

Virtual Box and Alt/Tab Keys

I use virtual box for all my testing activities. It comes too often that I have a virtual box VM window open & I want to switch to my host machine to see some stuff like tutorials etc.. If you press the alt+tab combination it just works inside the VM & doesn't switches to host machine. In these scenarios you can press the host key once ( not hold it ) & then whatever you press goes to host machine. So in general where host key is the default Right Ctrl, just press Right Ctrl once & now press the alt+tab & it will switch you out to host machine. This is really helpful when you have the VM windows open or you're working on seamless mode. Hope it help others too.

AMD Radeon™ HD 7670M on Ubuntu 12.04

Update:   Recently I install kubuntu 13.10 and there is no problem with graphics. It just works  fine out of the box. I've seen many blog posts on how to make AMD HD7670M work on Ubuntu 12.04, specially when its in switchable graphics board like Dell Inspiron 15R 5520. I tried many things to make it work so that I could use the cinnamon desktop on ubuntu & other things too.. But to my surprise even the drivers from AMD site didn't work. Then I tried a combination of those blog posts I read & somehow I became successful in running the full graphics including compiz settings inside My Ubuntu Machine. Following are the steps I followed & it worked... 1. Create a backup of your xorg configuration file: sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK 2. Remove/purge current fglrx and fglrx-amdcccle : sudo apt-get remove --purge fglrx* 3. Install the driver: sudo apt-get install fglrx fglrx-amdcccle 4. Install additional