Subset Repositories (Fedora 8)

If you are prepared to leave your install media in your machine (e.g. DVD in a DVD drive), or insert it every time you want to use yum or any yum-based tool, you don't need to do anything regarding the base repository; the out-of-the-box configuration for Fedora 8 will pull packages from your install media if required rather than download them from the Internet.

If you're not prepared to do that, follow the instructions here for creating and using a base repository based on an ISO image of the DVD media stored on your hard disk.

Creating the Base Repository

The base distribution repository is created in the same way as it's always been done on the earlier distribution releases. The files can be located anywhere but for the purposes of this article, the directory /srv/nb/distros/fc8 is used as a base.

To support both 32-bit and 64-bit machines on the network, the ISO images for both the 32-bit and 64-bit releases are needed. If you only need one architecture, skip the parts pertaining to the other architecture (similarly if you're using ppc, substitute ppc for i386 or x86_64 as appropriate).

The ISO images should be placed the repository area on the server that you are using, e.g.:

# mkdir -p /srv/nb/distros/fc8/os/i386/iso/
# cp Fedora-8-i386-DVD.iso /srv/nb/distros/fc8/os/i386/iso/

# mkdir -p /srv/nb/distros/fc8/os/x86_64/iso/
# cp Fedora-8-x86_64-DVD.iso /srv/nb/distros/fc8/os/x86_64/iso/

Create mount points so that the ISO images can be loopback-mounted:

# mkdir /srv/nb/distros/fc8/os/i386/dvd/
# chcon -t mnt_t /srv/nb/distros/fc8/os/i386/dvd

# mkdir /srv/nb/distros/fc8/os/x86_64/dvd/
# chcon -t mnt_t /srv/nb/distros/fc8/os/x86_64/dvd

Edit /etc/fstab and add entries for the DVD images to get them mounted at boot time:

/srv/nb/distros/fc8/os/i386/iso/Fedora-8-i386-DVD.iso /srv/nb/distros/fc8/os/i386/dvd iso9660 _netdev,ro,loop,fscontext=system_u:object_r:public_content_t:s0 0 0
/srv/nb/distros/fc8/os/x86_64/iso/Fedora-8-x86_64-DVD.iso /srv/nb/distros/fc8/os/x86_64/dvd iso9660 _netdev,ro,loop,fscontext=system_u:object_r:public_content_t:s0 0 0

<!> Note that these are just single long lines for each ISO image

It should now be possible to mount the ISO image(s) by issuing the command:

# service netfs start

It may seem strange to treat local loopback mounts as "network filesystems" but this is the point during the boot process where loopback mounts get done. Using service netfs start rather than plain mount -a checks that there are no SELinux issues (the former runs confined by SELinux, the latter does not). The long-winded mount options in the fstab entries prevent SELinux objecting if you serve out the repository using ftp, httpd, rsync etc.

You can then use createrepo to build the repository metadata:

# cd /srv/nb/distros/fc8/os/i386
# createrepo .

# cd /srv/nb/distros/fc8/os/x86_64
# createrepo .

/!\ Be careful with your directory hierarchy; it is important that the only RPM files that live in the /srv/nb/distros/fc8/os/i386 etc. directory or anywhere underneath that directory are the RPMs from your DVD ISO (i.e. the ones in the dvd/Packages 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.

{i} createrepo is in the createrepo package on the media

Using the Base Repository

Using the base repository is very straightforward. Simply edit /etc/yum.repos.d/Fedora-install-media.repo, comment out or remove the mediaid line, add a baseurl line as shown below and (optionally) turn back on GPG checks, so you end up with this:

name=Fedora 8
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY

The cost=500 line is a new feature in Fedora 8 that ensures that packages will be used from this repository rather than from the Internet.

You should now be able to test your setup by installing some package. Packages on the media will be shown as coming from InstallMedia and other packages will be shown as coming from fedora.

Creating the Updates Repository

The object here is to create an updates repository that contains only updates for the packages available on the original media. This will reduce the bandwidth and disk space needed to maintain the mirror.

The tool to be used is reposync, which is part of the yum-utils package.

The first step is to create lists of the packages on the media (and hence those we want to mirror updates for):

# cd /srv/nb/distros/fc8/os/i386
# ls dvd/Packages |
        awk '{ pkgname = $1; sub("-[^-]*-[^-]*$", "", pkgname); print "\t" pkgname }' |
        uniq > fedora-8-i386-dvd-pkgs.conf
# cd /srv/nb/distros/fc8/os/x86_64
# ls dvd/Packages |
        awk '{ pkgname = $1; sub("-[^-]*-[^-]*$", "", pkgname); print "\t" pkgname }' |
        uniq > fedora-8-x86_64-dvd-pkgs.conf

This process creates a sorted list of the packages on each DVD ISO (the lists are slightly different for each architecture), one per line, indented with a tab character at the start of each line. The tab character (or at least some form of leading space) is important for later use.

You need to ensure that you have the latest fedora-release package, which contains an updated set of GPG keys for the updates:

# yum update fedora-release

Now create a mirror configuration file, /etc/yum.repos.d/fedora-updates-mirror.repo:

name=Fedora 8 - i386 - Updates Subset

name=Fedora 8 - x86_64 - Updates Subset

<!> It's a good idea to replace the mirrorlist entries with baseurl entries pointing to a fast, nearby mirror; not all mirrors are as up to date as each other, so with the mirrorlist you might find that one day's reposync run removes the updates downloaded in the previous day's run.

Then create a script updates-sync, and put it somewhere in your PATH, such as /usr/local/bin:

echo "Updating mirror of fedora-8-updates-subset-x86_64"
reposync -n -g -d -a x86_64 -r fedora-8-updates-subset-x86_64 -p /srv/nb/distros/fc8 |
        grep -Ev "Skipping existing|%"
createrepo -q -d -C /srv/nb/distros/fc8/fedora-8-updates-subset-x86_64
echo ""

# Hard link i386 and noarch packages from the x86_64 repo to the i386 repo
# so as to avoid having to download them again, and to save space
commonpkgs=$(echo /srv/nb/distros/fc8/fedora-8-updates-subset-x86_64/*.{i386,noarch}.rpm)
if [ "$commonpkgs" != "/srv/nb/distros/fc8/fedora-8-updates-subset-x86_64/*.{i386,noarch}.rpm" ]; then
        ln -f $commonpkgs /srv/nb/distros/fc8/fedora-8-updates-subset-i386/

echo "Updating mirror of fedora-8-updates-subset-i386"
reposync -n -g -d -r fedora-8-updates-subset-i386 -p /srv/nb/distros/fc8 |
        grep -Ev "Skipping existing|%"
createrepo -q -d -C /srv/nb/distros/fc8/fedora-8-updates-subset-i386
echo ""

Skip the parts of the script for any architecture you're not interested in. The section in the middle hardlinking files between the x86_64 and i386 repos is only useful if you are mirroring both x86_64 and i386 updates. The grep command here reduces the volume of output from reposync whilst leaving the interesting output alone (unlike the -q option of reposync). Don't forget to make the script executable:

# chmod 755 /usr/local/bin/updates-sync

To populate the repository (download the update packages), just run /usr/local/bin/updates-sync. This will create repositories in directories /srv/nb/distros/fc8/fedora-8-updates-subset-i386 and /srv/nb/distros/fc8/fedora-8-updates-subset-x86_64 for i386 and x86_64 respectively.

Using the Updates Repository

Create a new repository configuration file /etc/yum.repos.d/fedora-local-updates.repo as follows:

name=Fedora $releasever - $basearch - Local Updates

{i} A low value for metadata_expire is used so that users of your local updates repo see the updates there very soon after you've sync'ed your mirror, and get fresh updates from there instead of downloading them themselves from the main updates repo over the Internat.

You should now be able to test your setup by running yum update. Packages in the local repository will be shown as coming from local-updates and other packages will be shown as coming from updates.

No/Slow Internet Connection?

Edit the configuration files:

  • /etc/yum.repos.d/fedora.repo

  • /etc/yum.repos.d/fedora-updates.repo

Change the line:




for the network repositories and leave just the local repositories enabled by default. You should then be able to use the package management tools whilst offline, though you may find that things you'd like to install appear not to be available.

To enable the Internet repositories for a single yum run whilst you're online, use:

# yum --enablerepo=fedora --enablerepo=updates update


# yum --enablerepo=fedora --enablerepo=updates install somepackage