Howto Setup yum repositories to update or install package from ISO CDROM Image

Original Post:

yum (Yellow dog Updater Modified) is a package manager for RPM compatible Linux systems such as CentOS, Fedora core and latest Redhat Enterprise Linux.

So how do you use yum to update / install packages from an ISO of CentOS / FC / RHEL CD?

Creation of yum repositories is handled by a separate tool called createrepo, which generates the necessary XML metadata. If you have a slow internet connection or collection of all downloaded ISO images, use this hack to install rpms from iso images.

Step # 1: Mount an ISO file

Type the following command (replace iso file name with the actual iso file):
# yum install createrepo
# mkdir -p /mnt/iso/{1,2,3}
# mount -o loop /path/to/centos1.iso /mnt/iso/1

Step # 2: Create a repository

Use createrepo to generate the necessary XML metadata. Type the following commands:
# cd /mnt/iso
# createrepo .

Clean repo, enter:
# yum clean all

Step # 3: Create config file

You need to create a repo config file in /etc/yum.repos.d/ directory.
# vi /etc/yum.repos.d/iso.repo
Append following text:
[My ISO Repository]

Save and close the changes.

Now use yum command to install packages from ISO images:
# yum install package-name

Original Post:

Installing Packages From Media

CentOS comes with an existing Yum configuration file for using the installation disc or ISO as a repository. By default this repository is disabled, and for good reason. Before we can use it, we need to both mount the ISO somewhere and then enable the repository.


Let’s start off by mounting our installation disc to the filesystem. We’re going to mount it to a new directory called CentOS in the /media directory.

  1. Create directory for mount.
    mkdir /media/CentOS
  2. Load the DVD/ISO.
  3. Mount the disc image to the newly created directory.
    mount /dev/cdrom /media/CentOS -t iso9600 -o loop

Enable the Yum Repository and Install Packages

Our disc is now mounted and now we need to enable the existing repository. This step will actually disable the Internet repositories and enable only the Media repository. For this to work, the disc must be mounted to the directory /media/CentOS.

  1. Enable Media repo and disable all others.
    yum --disablerepo=* --enablerepo=c6-media
  2. Install packages from the disc to your server using yum as you normally would.
    yum install package name

Disable the Yum Repository

After installing the packages, you may want to disable the media repository.

  1. Disable Media repo and enable all others.
    yum --enablerepo=* --disablerepo=c6-media
  2. Alternatively, you can just disable all repositories.<
    yum --disablerepo=*



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s