Wednesday, August 11, 2010

Create Yum repository from ISO file

The Linux flavor used here is RHEL5.

1. Mount the ISO image to /mnt/iso/
$ mkdir /mnt/iso
$ mount -o ro,loop /path/to/rhel-server-5.4-x86_64-dvd.iso /mnt/iso


or add this line to /etc/fstab
/path/to/rhel-server-5.4-x86_64-dvd.iso /mnt/iso iso9660 ro,loop 0 0
$ mount -a


2. Bootstrap - install createrepo
$ cd /mnt/iso/Server (it may be in some other folder)
$ rpm -Uvh createrepo*


3. Trouble with creating a repo of this mounted directory:
$ createrepo /mnt/iso/
Directory /mnt/iso/. must be writable.


4. Solution: Create another directory. Add a symlink to the mounted directories that contains the RPMs. Convert this new directory as the repo
$ mkdir /var/repo
$ ln -s /mnt/iso/Server /var/repo/rpms
$ ln -s /mnt/iso/VT /var/repo/rpms-vt

$ createrepo /var/repo

3040/3040 - rpms/zsh-html-4.2.6-3.el5.x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata


5. Create repo conf file
$ vi /etc/yum.repos.d/myrepo.repo
[rhel-myrepo]
name=myrepo
baseurl=file:///var/myrepo
enabled=1
gpgcheck=0


6. Test the new repo
$ yum list installed

1 comment:

Unknown said...

Thanks Man, I was trying to mount the iso at home directory but unable to run createrepo there. Hence I created a symlink in the /var/ftp/pub directory and createrepo works there. Really Worked.......Cheers...!!!!!