Create a Yum Repository from ISO Images

This page describes how to create a local yum repository from ISO images stored on the local hard disk. This repository can then be used for the [base] repository in your yum configuration, making package installation quick and easy.

Fedora 7 Onwards

From Fedora 7 onwards, the distribution media is only a small subset of the Fedora package collection, and so the process of creating and using a local repository from the media whilst retaining the ability to install packages not on the media is more complex. See SubsetRepositories for one approach.

Fedora Core 3, Fedora Core 4, Fedora Core 6

  1. Create a yum repository from your DVD
    • # mkdir -p /path/to/your/repo/dvd
      # chcon -t mnt_t /path/to/your/repo/dvd
      # mount -r -o loop /path/to/FC-6-i386-DVD.iso /path/to/your/repo/dvd
      # cd /path/to/your/repo
      # rpm -Uvh dvd/Fedora/RPMS/createrepo*
      # createrepo .

      /!\ Be careful with your directory hierarchy; it is important that the only RPM files that live in the /path/to/your/repo directory or anywhere underneath that directory are the RPMs from your DVD ISO (i.e. the ones in the dvd/Fedora/RPMS directory); any other RPMs that may be present will also be found by createrepo and included in the repository, which is probably not what you want.

  2. Ensure that the DVD ISO image is mounted at every reboot
    • edit /etc/fstab and add new line:

      /path/to/FC-6-i386-DVD.iso /path/to/your/repo/dvd iso9660 ro,loop 0 0
  3. Configure yum to use your new repository

    • edit /etc/yum.repos.d/fedora.repo or /etc/yum.repos.d/fedora-core.repo, whichever one is present

    • comment out any line starting with baseurl or mirrorlist

    • add a new line:
      baseurl=file:///path/to/your/repo

You should then be able to use your local repository to install new packages etc.

Fedora Core 5

It's particularly useful to set up a local [core] repository in Fedora Core 5 because pirut, the standard GUI package manager application, is built on yum and will hence take files from your local repository instead of having to go to the Internet to get them - pirut currently doesn't support installation from CD/DVD natively.

/!\ The metadata on the Fedora Core 6 DVD uses media: URLs, which yum does not understand, so it's necessary to take the same approach as for Fedora Core releases 3 and 4 in Fedora Core 6.

Using DVD ISO

In Fedora Core 5, the installer is based on yum and so there is actually yum repository metadata present on the DVD. This makes the process of setting up the local repository even easier, since you don't need to create the metadata yourself.

  1. Create a directory for your repository and mount the DVD ISO there:
    • # mkdir -p /path/to/your/repo
      # mount -r -o loop /path/to/FC-5-i386-DVD.iso /path/to/your/repo
  2. Ensure that the DVD ISO image is mounted at every reboot
    • edit /etc/fstab and add new line:

      /path/to/FC-5-i386-DVD.iso /path/to/your/repo iso9660 ro,loop 0 0
  3. Configure yum to use your new repository

    • edit /etc/yum.repos.d/fedora-core.repo

    • comment out any line starting with baseurl or mirrorlist in the [core] repository section at the top

    • add a new line:
      baseurl=file:///path/to/your/repo

Using CD ISO images

/!\ Note: I don't have the CD ISO images myself so I haven't tested this procedure with Fedora Core 5.

Creating a repository from CD ISO images is somewhat more complicated, since there are multiple images. There are a number of approaches that could be taken to work around this:

I've chosen to take the latter approach here.

  1. Create a directory on your system to hold the repository. It will need to be on a filesystem that has at least 3GB of free space. Then copy the RPM packages and comps.xml file from your CD images into it.

    • # mkdir -p /path/to/your/repo/RPMS
      # cd /path/to/your/repo
      # mkdir disc1 disc2 disc3 disc4 disc5
      # mount -r -o loop /path/to/FC-5-i386-disc1.iso disc1
      # mount -r -o loop /path/to/FC-5-i386-disc2.iso disc2
      # mount -r -o loop /path/to/FC-5-i386-disc3.iso disc3
      # mount -r -o loop /path/to/FC-5-i386-disc4.iso disc4
      # mount -r -o loop /path/to/FC-5-i386-disc5.iso disc5
      # cp disc*/Fedora/RPMS/* RPMS
      # cp disc1/repodata/comps.xml .
  2. You no longer need the CD images, so you can unmount them and remove the mountpoint directories.
    • # umount disc1 disc2 disc3 disc4 disc5
      # rmdir disc1 disc2 disc3 disc4 disc5
  3. Create the repository metadata.
    • # rpm -Uvh RPMS/createrepo*
      # createrepo -g comps.xml .
  4. Configure yum to use your new repository

    • edit /etc/yum.repos.d/fedora-core.repo

    • comment out any line starting with baseurl or mirrorlist in the [core] repository section at the top

    • add a new line:
      baseurl=file:///path/to/your/repo

Using Add/Remove Software With No Network Connection

If you want to use the Add/Remove Software application (pirut) with no network connection, you'll need to disable all of the yum repositories apart from your local one. By default, the only enabled repositories are core (which is now served by your local repository), updates, and extras. You can disable these repositories by changing the line enabled=1 to enabled=0 in /etc/yum.repos.d/fedora-updates.repo and /etc/yum.repos.d/fedora-extras.repo respectively.

If at a later time you have an Internet connection available and would like to update your system or install something from Fedora Extras, you can enable these repositories on the yum command line without needing to edit the .repo files again, e.g.:

# yum --enablerepo=updates --enablerepo=extras update
# yum --enablerepo=updates --enablerepo=extras install somepackage


CategoryTip

last edited 2008-01-31 12:32:06 by localhost