Friday, November 30, 2012

Update Redhat Enterprise Linux with yum using the base install CD as a repository

I want yum, the update utility in Redhat Linux, to pick up files from the install CD. I find this simpler as I usually run Linux on virtual machines and the cd remains mapped and accessible. I am running redhat enterprise linux 6.2

Here's what I did:

  1. Create a directory to mount the cd into. Here's the command:
    mkdir /media/rhel62
  2. Mount RHEL 6 ISO to /media/rhel6 here's the command:
    mount -o loop RHEL6.2-20111117.0-Server-x86_64-DVD1.iso /media/rhel62
  3. Copy media.repo file from the RHEL ISO to /etc/yum.repos.d/ here's the command:
    cp /media/rhel62/media.repo /etc/yum.repos.d/rhel6.repo
  4. Configure the repo file to point to the /media/rhel6. To do so  open the file /etc/yum.repos.d/rhel6.repo and add following line
    baseurl=file:///media/rhel62/Server
    It is a good idea to change the repo name by changing the string contained in the [ ] at the beginning of the file
  5. Create the repository package. Here's the command:
    yum install createrepo
  6. Create a directory to store the repodata file into and create the repository. I used /repodata. So the commands are:
    mkdir /repodata
    cd /repodata
    createrepo .
  7. Finally clean up
    yum clean all 

From now on every yum install command will get the updates from the CD.
Don't forget to automount the iso image, so that your settings are preserved after a reboot.
To do so add the following line in /etc/fstab:

/tmp/RHEL6.2-20111117.0-Server-x86_64-DVD1.iso /media/rhel62     iso9660 loop,ro,auto    0       0



Please Note: if you want to use the same method for other features in Redhat linux such as HighAvailability , LoadBalancer , ResilientStorage and ScalableFileSystem then you 'll need to add more lines in the rhel6.repo file. Here's a link to the source of the information I presented:
https://access.redhat.com/knowledge/node/9743