Adding RedHat DVD as Repository

When we try out a new linux OS its always a pain to download and install all the software and  add packages we needs on that. Its even worse if you don’t have an unlimited connection. But actually most of the software we need is already there in the CD/DVD in which the operating system comes with. So how do we install from the DVD then rather than from the internet?
For this you need to add the DVD as a repository so that rpm client picks up the rpm from the DVD and wont go to internet for it.
The Procedure and Files to be modified is a bit different for each OS so i will cover Red Hat Linux in this post.
In RHEL the repo list is maintained in the folder /etc/yum.repos.d/ . So lets create a new file in this directory , say lets call it rhel-cd.repo.
The Contents of this file should be as follows:

name=Red Hat Enterprise Linux $releasever - $basearch - CD

First line ([rhel-cd]) should be an unique value ie no two repo file should have the same value or it will show a warning.

Name can be anything it is for the user to identify it when its shown though the rpm interface.

baseurl should point to the DVD mount point. For this we first identify the file repomd.xml. This file should be in the folder repodata. Thus we should include the folder path to the parent folder to repodata in the baseurl.
Eg: In my DVD path to repomd.xml is /media/RHEL/Server/repodata/repomd.xml , then I include /media/RHEL/Server/ in the baseurl as file:///media/RHEL/Server/

enabled should be 1 if the repo should be taken by rpm on searching for sources.

gpgcheck can be enabled if you have the gpg file for the cd. Lets leave it disabled for now.

Now save the file and close it. So the configuration for adding a new repo is done. If you have any more .repo files in the folder /etc/yum.repos.d/ then open those and disable ( by making enabled=0) those for now as rpm might choose them over cd repo and it will prompt for downloading from internet. After doing that also we need to clean the cache of yum so that it re-reads the repodata and caches again. This is essential as then only the changes made to .repo files get reflected. You can clean cache by the command

yum clean all

Now you can install new rpms from the DVD by using yum command.
So try it out and tell me how it goes and tell me if it doesn’t work or if you need some help

, , , , , , , ,

  1. #1 by Trance on April 4, 2010 - 7:59 pm

    it so nice article but I’m from Ukraine and it’s one reason why I don’t understend ENglish on full level
    but THXX=)

  2. #2 by bormenatal on July 23, 2010 - 4:11 pm

    well done! thanks. Useful information for me.

  3. #3 by kiran on November 5, 2010 - 1:51 am

    i got error

    yum grouplist
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Group Process
    file:///media/RHEL/Server/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/media/RHEL/Server/repodata/repomd.xml’
    Trying other mirror.
    file:///media/RHEL/Server/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/media/RHEL/Server/repodata/repomd.xml’
    Trying other mirror.
    Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhel-cd. Please verify its path and try again

  4. #4 by incuccignifut on January 9, 2011 - 4:38 am

    Very Interesting Post! Thank You For Thi Post!

  5. #5 by incuccignifut on January 9, 2011 - 4:39 am

    You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.

  6. #6 by Bryan on January 7, 2012 - 12:32 am

    I followed these steps under Fedora 16 but kept getting the error “Cannot retrieve repository metadata (repomd.xml) for repository: updates. Please verify its path and try again.” I ended up renaming my other .repo files (i.e. mv fedore.repo fedore.repo.old) and then it worked. For some reason even though all the other repository definitions were disabled, yum was still trying to look them up on the Internet. (My Fedora PC didn’t have Internet access.)

  7. #7 by Rohan on February 3, 2012 - 7:00 pm

    Great post dude!!! Thanks :)

  8. #8 by John on February 28, 2012 - 8:21 am

    Thanks for the writeup; quite useful!

  9. #9 by allamiro on June 23, 2012 - 5:08 am

    I did

    rpm -import /mnt/rhel/RPM-GPG-Relase

    then created the rhel.repo on /etc/yum.repos.d

    run yum list to get the error

    cd to /etc/yum.repos.d

    then mv your rhel.repo to redhat.repo

  10. #10 by Zahid Haseeb on June 25, 2012 - 5:36 pm

    Great work man. I tried it and it worked.

  11. #11 by Sam M on June 29, 2012 - 6:04 pm

    Thanks for the info. Confirmed working on RHEL Server 6.3 Install DVD

  12. #12 by evangelos on January 6, 2013 - 8:53 am

    Very good! thanks

  13. #13 by film telecharger hd on March 6, 2014 - 5:20 am

    If you are going for best contents like me, just pay a quick visit this web page every day because it offers feature contents, thanks

(will not be published)