TuXHaT


Linux / sysadmin / Debian / Ubuntu / Red Hat / Centos

How to setup local yum repository for centos 5 media

By tux • Mar 10th, 2009 • Category: centos

You should already have /etc/yum.repos.d/CentOS-Media.repo after installing centos. If you don’t have one create as below,

[c5-media]
name=CentOS-$releasever – Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
enabled=0

Then mount your cdrom to either /media/CentOS/ | /media/cdrom/ | /media/cdrecorder/,

mount /dev/cdrom /media/cdrom

So now your yum repository for centos5 is readyat /media/cdrom.

To install a package from the centos media repository created,

yum –disablerepo=\* –enablerepo=c5-media install <package name>

By default the repositry named c5-media here will be disabled as enabled=0 is given in /etc/yum.repos.d/CentOS-Media.repo. The above command will disable all other repositries and enable the c5-media alone.

Enjoy installing :)

Tagged as: , , ,

tux is
Email this author | All posts by tux

3 Responses »

  1. Hi all,

    The info provided above is not only enough for the problem specified. Most of the normal Linux users didn’t prefer to install from command link using the command mentioned above. For installing packaged from the DVD ROM by disabling online checking for repos, please follow the steps below :

    There are two important files we need to edit for achieving the above goal.

    File 1 : /etc/ yum.repos.d/CentOS-Base.repo

    Edit the above mentioned file and add the line “enabled=0″ in every section. After that the file will look like this :

    # CentOS-Base.repo
    #
    # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client. You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the
    # remarked out baseurl= line instead.
    #
    #

    [base]
    name=CentOS-$releasever – Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    #released updates
    [updates]
    name=CentOS-$releasever – Updates
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    #packages used/produced in the build but not released
    [addons]
    name=CentOS-$releasever – Addons
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
    #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever – Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever – Plus
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    #contrib – packages by Centos Users
    [contrib]
    name=CentOS-$releasever – Contrib
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

    File 1 : /etc/ yum.repos.d/CentOS-Media.repo

    Edit the above mentioned file and change the line “enabled=0″ to “enabled=1″. After that the file looks like this :

    # CentOS-Media.repo
    #
    # This repo is used to mount the default locations for a CDROM / DVD on
    # CentOS-5. You can use this repo and yum to install items directly off the
    # DVD ISO that we release.
    #
    # To use this repo, put in your DVD and use it with the other repos too:
    # yum –enablerepo=c4-media [command]
    #
    # or for ONLY the media repo, do this:
    #
    # yum –disablerepo=\* –enablerepo=c4-media [command]

    [c5-media]
    name=CentOS-$releasever – Media
    baseurl=file:///media/CentOS/
    file:///media/cdrom/
    file:///media/cdrecorder/
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta

    After doing these two things, try installing packages from “Add/Remove Software” . It will never check for online repos and will install packages from DVD itself.

    Hope you enjoyed the help. Happy installing. Feel free to contact TUXHAT for doubts and queries in Linux.

    Regards,

    Amjad A.R.
    Phone : 0 9895448361

  2. Hi All,

    If you are getting a ‘YUM Public key check error’ after doing the above steps then once again edit the file

    /etc/ yum.repos.d/CentOS-Media.repo

    and change the line “gpgcheck=1″ to “gpgcheck=0″.

    This will solve the problem.

    Regards,

    Amjad A.R.
    Phone : – 0 9895448361
    Engineer, Embedded Systems.
    Admin,Networks and Systems.

  3. Hi!

    Thx for article it helped me a lot..

Leave a Reply

CAPTCHA Image CAPTCHA Audio
Refresh Image