I’m writing this under the Fedora Core 6 category since I am currently running Fedora Core 6 on my home machines. BUT, I am setting up a Yum Repository in preparation for the upcoming Fedora 7 release due out at the end of the month. I will replicate this with fresh installs of Fedora 7 once it is released.
This article not only covers setting up and running a Yum Repository but it covers one way to mirror a distro as well (in our case Fedora). I find it very convenient to have a local mirror on my lan.
Running a Yum Repository for a local lan has a few benefits. For me the primary benefit is bandwidth savings.
This article is not for the beginner. One should be familiar with administration of a Linux machine.
I have several Fedora desktop machines in my home sharing a modest SBC DSL line with 6016kbps/768kbps speed. I have one Fedora machine dedicated to a server role behind my hardware firewall/router.
To accomplish the task of setting up a Yum Repository I first needed to aquire the software from a fast mirror. One can locate Fedora mirrors by visiting the Fedora Mirrors List.
I plan to mirror the OS, Extras, and Updates repositories for Fedora Core 6 on the i386 platform since I don’t yet own PPC or x86_64 machines. I will also exclude development and testing repos.
I know there are several methods of mirroring and even setting up a repository. I chose to do it this way to learn a little more about Yum, cron, and rsync.
Before we begin please be aware that even with 6000kbps download rates such as mine the intital mirroring of a distro will take a long time.
I chose a mirror from the Fedora Mirrors List and decided to use rsync to get the files.
I used rsync because once the initial mirror has been established locally only changes to the mirror will be downloaded to my local machine as I maintain the repository.
To mirror the repos I simply issued these commands as the root user (each on one line):
Fedora Core 6
rsync -avrt --progress rsync://mirrors.kernel.org/fedora/core/6/* --exclude ppc --exclude x86_64 --exclude repoview /var/ftp/pub/fedora/core/6/
… wait a long time …
rsync -avrt --progress rsync://mirrors.kernel.org/fedora/extras/* --exclude repoview --exclude development --exclude 5 --exclude 4 --exclude 3 --exclude ppc --exclude x86_64 /var/ftp/pub/fedora/core/extras/
… wait a long time …
rsync -avrt --progress rsync://mirrors.kernel.org/fedora/core/updates/6/* --exclude repoview --exclude testing --exclude 5 --exclude 4 --exclude 3 --exclude 2 --exclude 1 --exclude ppc --exclude x86_64 /var/ftp/pub/fedora/core/updates/6/
… wait a long time …
A long time could be half a day or longer. I took me the better part of 36 hours to complete all three commands.
After the mirroring is complete you are basically good to go if the mirror you have is accessible via ftp or httpd (I won’t explain how to do that in this article). Just point your yum client at http://your.private.ip/path_to_repo by editing your files for ‘core’, ‘extras’, and ‘updates’ located in /etc/yum.repos.d
See the Managing Software with Yum documents for more information.
Maintaining/Creating a Repo
If you want to you could exclude the ‘repodata’ directories as we rsync’d the files earlier. However, in doing so your mirror will need to be setup as Yum Repository by using the ‘createrepo’ command. YOU DO NOT HAVE TO DO THE NEXT STEPS UNLESS YOU ARE AS CURIOUS AS I WAS.
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/6/i386/debug/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/6/i386/os/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/6/i386/os/Fedora/RPMS/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/6/source/SRPMS/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/extras/6/SRPMS/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/extras/6/i386/debug
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/extras/6/i386/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/updates/6/SRPMS/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/updates/6/i386/debug/
createrepo -q -c /var/www/cache /var/ftp/pub/fedora/core/updates/6/i386/
… etc. You do this for each directory in the tree you wish to be available to Yum. I looked at the mirror directory trees to see which directories contained the ‘repodata’ directories and ran ‘createrepo’ for those directories.
You can set the rsync commands and the createrpo commands to run periodically in cron jobs to keep your local repo synced with the official mirror. The rysnc command will only take from a few seconds to a few minutes to run after the initial mirror is created. This is because rsync will only download changed or additional files.
Just be sure that if you use the createrpo command that they run AFTER the local repo is updated to the official repo.
There are scripts out there to automate mirroring and setting up a repo. One I can think of is mrepo available from Dag Wieers. mrepo does a lot more than just mirror a repo.