Create a Local Fedora 16 Repository
If you have several Fedora systems you can create your own local repository to reduce the amount of Internet traffic and control the updates you want to have available. Also, you can create repositories for other products you use or like. In this post we will cover creating a local Fedora 16 repository.
Update: You can use this same process on Fedora 17 & 18, just change the version number.
Two requirements are disk space and Apache installed.
Install Apache if it is not installed already.
$ sudo yum -y install httpd
Create the directories that become the local repository.
$ sudo mkdir -p /var/www/html/pub/F16-x86_64/releases $ sudo mkdir -p /var/www/html/pub/F16-x86_64/everything $ sudo mkdir -p /var/www/html/pub/F16-x86_64/updates
Install the remote synchronization tool rsync.
$ sudo yum install rsync -y
Use rsync to populate your repository.
/usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/updates/16/x86_64/ –exclude=debug/ /var/www/html/yum/F16/updates /usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/ /var/www/html/yum/F16/everything
Create a cron.daily job for the rsync process. The following synchronizes daily.
$ sudo touch /etc/cron.daily/updrepo16.cron $ sudo gedit /etc/cron.daily/updrepo16.cron
Paste the lines of code below into the updrepo16.cron file. Note, change to a mirror of your choice. Get the list of available rsync mirrors from http://mirrors.fedoraproject.org/publiclist/Fedora/16/x86_64/
#!/bin/bash /usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/updates/16/x86_64/ --exclude=debug/ /var/www/html/yum/F16/updates >> /var/log/rsync16upd.log /usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/ /var/www/html/yum/F16/everything >> /var/log/rsync16.log
Then save the file.
This also creates and appends two log files rsync16upd.log and rsync16.log in the /var/log directory.
The first time the repository synchronizes it may take considerable time and bandwidth.
If you do NOT plan to make a full mirror of an existing Fedora repository you should use the createrepo tool to create and populate the data files and directories correctly.
$ sudo yum install createrepo
Then
$sudo createrepo --database /var/www/html/yum/F16/everything $sudo createrepo --database /var/www/html/yum/F16/updates
Now you have created several repository’s for Fedora 16.
Next create files in my local /etc/yum.repos.d/, called local.repo and localupdates.repo
local.repo
[local] name=Fedora $releasever – $basearch failovermethod=priority baseurl=http://192.168.1.101/yum/F16/everything/x86_64/ #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch enabled=1 metadata_expire=7d gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
localupdates.repo
[local-updates] name=Fedora $releasever – $basearch – Updates failovermethod=priority baseurl=http://192.168.1.101/yum/F16/updates/x86_64/ #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
Then I copy those two files to all of my systems running Fedora. You should now be able to do a yum update and install and grab the files from your system.
thanks 😛 ill try to use this for fedora 17
one question, i need put a local repo in my network (over 40 pc’s with fedora 17and18) and i don’t plan to make a full mirror of an existing Fedora repository! but in the second part i don’t see the remote synchronization ? How make a synchronization with fedora repos? thnx
Actually it is there. You use rsync to perform the updates.
Install the remote synchronization tool rsync.
$ sudo yum install rsync -y
Use rsync to populate your repository.
/usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/updates/16/x86_64/ –exclude=debug/ /var/www/html/yum/F16/updates
/usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/ /var/www/html/yum/F16/everything
Create a cron.daily job for the rsync process. The following synchronizes daily.
$ sudo touch /etc/cron.daily/updrepo16.cron
$ sudo gedit /etc/cron.daily/updrepo16.cron
Paste the lines of code below into the updrepo16.cron file. Note, change to a mirror of your choice. Get the list of available rsync mirrors from http://mirrors.fedoraproject.org/publiclist/Fedora/16/x86_64/
#!/bin/bash
/usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/updates/16/x86_64/ –exclude=debug/ /var/www/html/yum/F16/updates >> /var/log/rsync16upd.log
/usr/bin/rsync -avrt rsync://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/ /var/www/html/yum/F16/everything >> /var/log/rsync16.log
Then save the file.
the first line, works, but the second line
rsync -avrt rsync://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/ /var/www/html/yum/F16/everything >> /var/log/rsync16.log
not work!
if you try to access to:
http://mirrors.kernel.org/fedora/everything/16/x86_64/os/Packages/
The requested URL /fedora/everything/16/x86_64/os/Packages/ was not found on this server.
i try to meke this with fedora 18 and the firts line works fine x me:
rsync -avrt rsync://mirrors.kernel.org/fedora/updates/18/x86_64/ –exclude=debug/ /var/www/html/yum/F18/updates >> /var/log/rsync16upd.log
but
rsync -avrt rsync://http://mirrors.kernel.org/fedora/releases/18/Everything/x86_64/os/Packages/ /var/www/html/yum/F18/everything >> /var/log/rsync16.log
not working! any idea ??
Try rsync -avrt rsync://mirrors.kernel.org/fedora/releases/18/Everything/x86_64/os/Packages/ /var/www/html/yum/F18/everything >> /var/log/rsync16.log
You had rsync://http:// in your command. Should be just rsync://
thnx!
ok i found the error:
is
rsync -avrt rsync://mirrors.kernel.org/fedora/releases/18/Everything/x86_64/os/Packages/ /var/www/html/yum/F18/everything >> /var/log/rsync16.log
not
rsync -avrt rsync://http://….
yeap work fine! thnx !