Articles

Local Ubuntu Repository

In Archived on September 17, 2010 by netritious


When I first set out using Ubuntu last year I tried using apt-cacher to minimize the amount of traffic to and from my network and Ubuntu servers for updates.

Why? Because the experience of installing a package or updating a fresh Ubuntu installation takes a fraction of the time, saves bandwidth, frees up Ubuntu servers, and works when an internet connection is unavailable.

apt-cacher did not work out for me, probably because I was so green at the time. However, the process described in the Ubuntu Community Documentation about using debmirror is straight forward and thorough. So far following this guide has provided me with good results.

Here are some tips and tricks before running the debmirror script from the community documentation:

  1. Don’t create a mirror for a single computer. It’s a complete waste of time, effort, and bandwidth if you do IMHO.
  2. Use the list at https://launchpad.net/ubuntu/+archivemirrors to find an official Ubuntu mirror instead of using the default <your country>.archive.ubuntu.com. Consider speed and latency from the hosts that are available in your country from the list. I used the Argonne National Laboratory mirror in Chicago, IL, since it was up to date, offers a fast 10Gbps connection, and had a low ping latency.
  3. Do your initial run from a selected mirror to speed up the process, but change your config in the script from the documentation back to <suitable-mirror>.archive.ubuntu.com, and re-sync. I had over 75 HTTP 404 errors after the first run and changing to use us.archive.ubuntu.com resolved the issue.
  4. Prepare to give up 100-200 GB of storage space somewhere on your network. As of 12pm today:
    netritious@myob:~# du -s -h /usr/local/mirror/
    89G	/usr/local/mirror/
  5. Prepare for your connection downstream to become congested during the first few syncs. If you have less than a 3Mbps connection, it will take a few days. I have a 16Mbps connection and it still took about 36 hours and the speed averaged (almost) 7Mbps.
  6. If you followed the documentation for debmirror to a ‘T’ then you will need to remove the line from the script that contains –progress so your cron generated emails aren’t a mile long.
  7. Again, if you followed the tutorial to a ‘T’ then like myself you may be wondering what the effect of only mirroring the .deb’s and not the deb-src are in the sense of installing packages that require building some dependency from source. To be honest I’m uncertain if it has any affect at all. I have installed at least 50 or packages with my new local repository and haven’t seen any ill effects.

In comparison, this is something that is very convoluted with Microsoft products. I was never happy with the amount of work involved to keep local machines updated from a local source be it from a network share or CD/DVD media. In my opinion there are fewer caveats with a locally hosted Ubuntu mirror.

Here is the final script that now runs every twelve hours.

#!/bin/bash
#/usr/local/bin/debmirror-build.sh
# Credits: https://help.ubuntu.com/community/Debmirror

export GNUPGHOME=/home/mirrorkeyring
arch=i386,amd64
section=main,restricted,universe,multiverse
release=hardy,hardy-security,hardy-updates,lucid,lucid-security,lucid-updates
server=us.archive.ubuntu.com
inPath=ubuntu
proto=http
outPath=/usr/local/mirror

debmirror -a $arch
--no-source
-s $section
-h $server
-d $release
-r $inPath
-e $proto
$outPath
Donate a comment if you found this useful. ;)

Updated (22:58): Fixed grammar and typos. Added example of current mirror size. Added my adjusted script from the debmirror Ubuntu Community Documentation.
About these ads

One Response to “Local Ubuntu Repository”

  1. Pretty cool! I noticed when I set up my first Ubuntu instance on AWS that the package downloads were instantaneous. This is a great feature for your customers.

    (I work with Mike Howles and he linked me to your site.)

Comments are closed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: