How to create a local update repository for FC6 LAN computers.

Jan 4, 2007 10:16 GMT  ·  By

Because Fedora Core is an RPM based Linux distribution, it's quite easy to keep it up to date. Fedora can easily be updated through yum, an update tool which fetches the latest RPM packages from a mirror and installs them. A mirror is a server that provides a copy of one or more files. Mirroring a site reduces traffic to the original source site and spreads the stress and bandwidth costs across other sites. Running a local mirror however, offers very fast access through the LAN connection to local users. Think about it this way: if you're the network admin of a network composed of Fedora Core systems, those systems will need to be updated at some point. And because they are all using the same distribution, the downloaded update packages will be the same. So basically, the computers in that network will use your precious bandwidth to download the same update files, several times, at rather low speeds. Pointless. A local update mirror will prevent unnecessary bandwidth usage by downloading the packages once and then provide them to the local computers at blazing speeds.

1. Install createrepo and repoview

code
yum -y install createrepo repoview
You will also need a working Apache (httpd) and Cron installation on your system.

2. Create the directories

code
mkdir -pv /var/www/html/yum/{base,updates}
mkdir -v /var/www/html/yum/updates/6
mkdir -v /var/www/cache
3. Copy the RPMs from the Fedora Core 6 CDs/DVD to /var/www/html/yum/base

4. Create the base repository headers

code
createrepo /var/www/html/yum/base
This command will create a new directory, repodata, within the base directory and will contain the files: filelists.xml.gz, other.xml.gz, primary.xml.gz and repomd.xml. This process will take some time, depending on your CPU and disk speed.

5. Select an rsync updates mirror

- Click HERE and choose the nearest mirror which starts with rsync://.

6. Synchronize the local updates directory with the mirrored one

- Append /updates/6/i386 to the chosen rsync mirror. For example, if you choose: rsync://sunsite.icm.edu.pl/fedora/linux/core/, it becomes: rsync://sunsite.icm.edu.pl/fedora/linux/core/updates/6/i386.

- Synchronize the local directory content with the remote one:

code
rsync -avrt rsync://sunsite.icm.edu.pl/fedora/linux/core/updates/6/i386
--exclude=debug/ --exclude=repodata/ --exclude=*debuginfo* --exclude=*i18*
--exclude=*langpack* /var/www/html/yum/updates/6
NOTE: The Romanian rsync address (iasi.roedu) isn't correctly written. The correct rsync address is rsync://ftp.iasi.roedu.net/fedora-core-updates/6/i386.

- Create the repository headers:

code
createrepo -q -c /var/www/cache/ /var/www/html/yum/updates/6/i386
- Create the RSS feed:
code
repoview -qu http://localhost/yum/updates/6/i386 /var/www/html/yum/updates/6/i386
Replace localhost with your webserver address.

7. Create a daily cron script

- Create a new file

code
touch /etc/cron.daily/repository
- Open it using your favorite text editor and add this content, after you've modified it to suit your system:
code
#!/bin/bash

rsync -avrt rsync://sunsite.icm.edu.pl/fedora/linux/core/updates/6/i386
--exclude=debug/ --exclude=repodata/ --exclude=*debuginfo* --exclude=*i18*
--exclude=*langpack* /var/www/html/yum/updates/6

createrepo -q -c /var/www/cache/ /var/www/html/yum/updates/6/i386

repoview -qu http://localhost/yum/updates/6/i386 /var/www/html/yum/updates/6/i386

exit 0
At this point, only new updates and headers will be downloaded to your repository, once a day.

8. Edit yum configuration file

- You will now have to edit the /etc/yum.conf file on every local network machine that will use the new repository. Add the following content to the end of the yum.conf file:

code
[updates-released]
name=Fedora Core $releasever - $basearch - Released Updates
#mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc$releasever
baseurl=http://192.168.0.xx/yum/updates/$releasever/$basearch/
enabled=1
gpgcheck=0

[base]
name=Fedora Core $releasever - $basearch - Base
baseurl=http://192.168.0.xx/yum/base/RPMS
#mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-$releasever
enabled=1
gpgcheck=0
NOTE: You will have to replace the 192.168.0.xx address with the correct server's LAN address. Moreover, on the machine holding the repository, replace that address with localhost.

- Now edit the /etc/yum.repos.d/fedora-updates.repo file on each machine and disable the updates section. To do this, look for the line enabled=1 under the [updates] section and replace it with enabled=0.

If everything worked out well, you should be able to run yum update from any of the local computers and it will use the local repository as the update mirror.