Yum repository using dvd and also permanent local yum repository

Creating yum repository

RPM and YUM in redhat and centos. We use rpm and yum to install packages in Linux operating systems such as redhat, centos, fedora, and scientific linux.
    Yum is the package manager for redhat and its derivatives. Yum stands for yellow-hat update modifier. All the packages in redhat will have .rpm extension for eg ( httpd-2.2.15-53.el6.centos.x86_64.rpm).

    You can use either rpm or yum to install a package.While using rpm the package has to be available in the local machine. For example to install a package called some.rpm use:
rpm -ivh /tmp/rhel6/some.rpm (/tmp/rhel6/ being the path where the rpm is stored, and some.rpm being the package name). Here are the few options to use with rpm: 

  • rpm -ivh path to the rpm (to install )
  • rpm -qa name of the rpm (to query if package is installed or not)
  • rpm -Uvh path to the rpm ( to update already installed package)
  • rpm -e name of the package (to uninstall the package

    One disadvantage of the rpm is, if you want to install the package that has dependency , rpm will not be able to resolve the dependency by itself . So you have to install the dependency first and then you will be able to install the rpm. For example:
If you try to install the createrepo-0.9.9-18.el6.noarch.rpm you will get a error saying cannot resolve dependency and also the dependency name. So you will have to install the dependency first. Then if you try to install the dependency , also it will have dependency, so you will have to install the second dependency then the first dependency then you will be able to install createrepo-0.9.9-18.el6.noarch.rpm
try rpm -ivh createrepo-0.9.9-18.el6.noarch.rpm

    When that does not work try to install the deendency as following then the package installation will work.

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


Yellowhat update modifier is the package manager for redhat which has lots of advantages over rpm, the first being yum can resolve dependencies automatically.But in order to enable yum you need to have connection to the repository. You can achieve that with different method.
1) If you have internet connection in the machine and have redhat license then you can register to redhat using redhat_register, then you can use redhats repository to install and update new packages
2)If you have internet and you have url to the yum server
3)If you have local yum repo in your environment then you can get packages from that yum server
4)If you are trying to use yum for temporary period of time you can use dvd as a repo also
5)Or you can create your own local yum repository
    We will be learning how to create yum repository from dvd and also will learn how to set up local yum repo.

Yum from DVD

1) to create yum repository from dvd you need to have a redhat iso
2) when you get redhat iso attach to the virtualmachine by going to the virtualbox and storage
3) then you will have to mount the dvd to a directory to gain access to the data in the dvd
4) mount /dev/cdrom /mnt or mount /dev/sr0 /mnt
/dev/cdrom or /dev/sr0 is the devicename for dvd drive and we are mounting dvd to /mnt ( /mnt is an empty directory created with the sole purpose to mount the removable media like dvd, you should not create any other files or directories in that /mnt directory, this should be used only to mount the dvd .
5) Once dvd is mounted verify this with ls -l /mnt command, if you see the contents then dvd is mounted
6) ls -l /mnt/Packages ( this is the main directory where you .rpm packages are kept, if you want to install packages using rpm you can give the path as follows
rpm -ivh /mnt/Packages/rpm -ivh createrepo-0.9.9-18.el6.noarch.rpm
7)We have package avaliable now we need to let yum know where the packages are, we do this by creating a repo file.
8) Repo file is a file that ends with .repo extension and is inside /etc/yum.repos.d directory
9) cd /etc/yum.repos.d ls -l
10) you can name the repo file any name. it just need to have a .repo extension
11) we will name our repofile dvd.repo
12)vi /etc/yum.repos.d/dvd.repo then u need to write some information inside it
[media] # This is the id of the repo (you can name it any thing)
name=RedHat-yum-Dvd # This is the name of the repo (you can name it anything)
baseurl=file:///mnt/ #[path of the iso folder] (in our case we mounted the dvd in /mnt so we need to give baseurl=file:/// then the file name)
enabled=1 # to enable the repo when required or to disable to repo when not required to enable 1 and to disable 0
gpgcheck=0 # this is to enable or disable key check, to enable 1 do disable 0, if 1 then gpgkey
13) yum clean all ( after you make any change to repo file use this command to clean the cache and get new information from repo file)
14)yum repolist ( to list the avaliable repo) , if you see repolist: and some number that means yum setup is complete if you see 0 that means there is something wrong.

Local repo

1) mount dvd to /mnt
mount /dev/sr0 /mnt
2) mkdir -p /var/www/html/rhel6 ( we created a directory to copy the packages)
3)cp -arv /mnt/Packages/* /var/www/html/rhel6 ( copy packages from mount point to the directory you just created)
4) Now we need to use create repo command to setup repository , this command will not be installed so you will have to install it manually)
5) cd /mnt/Packages ( we will go the /mnt/ directory where we mount the dvd and go to Packages directory where rpms are avaliable
then install createrepo package, since it has dependency, install dependency first ( the version might be different so check the version avaliable in you system just dont copy paste it)
  • 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-18.el6.noarch.rpm
6)createrepo /var/www/html/rhel6/ ( now use createrepo command to create a repository in the directory where you copied the rpms)
Now we will create a repofile to tell the system where it the repo avaliable
7)cd /etc/yum.repos.d
8) vi /etc/yum.repos.d/local.repo
9) yum clean all
10) yum repolist
Few yum commands
  • yum install vsftpd   ( to install)
  • yum list vsftpd ( to list if package is installed or avaliable)
  • yum remove vsftpd ( to remove package)
  • yum update (update all the packages in the system


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.