Tuesday, July 20, 2010

Setup yum repository for update/install from ISO image

After the RHEL5 installation without the registration key, it is not possible to get repository updates/setup as system is not registered with RHN (Red Hat Network). However, yum repository can be setup using the local RHEL ISO image in following steps:


1. Create directory for mounting
  $ mkdir -p /cdrom/iso

2. Mount the iso at the loopback device
  $ mount -o loop </path/to/iso-file> /cdrom/iso

3. Create a repository using the the mounted directory
  $ cd /cdrom
  $ createrepo .
  $ yum clean all

4. Create a yum repo file
  $ cat /etc/yum.repos.d/file.repo
     [RHEL]
     baseurl=file:///cdrom/
     enabled=1
     gpgcheck=0

Troubleshoot:
  * If createrepo package is not installed, find it into the mounted directory & and install first
   $ find /cdrom/iso/ -name "*createrepo*"
   $ rpm -ivh /cdrom/iso/Server/createrepo*.rpm 


Mounting permanently:
To mount /cdrom/iso permanently, a entry need to made in /etc/fstab
/iso-name /cdrom/iso iso9660 ro,loop 0 0

No comments: