Bonus entry: Squid to cache Ubuntu net installs

2006 December 23
by darkness

I install enough boxes at home that I’ve got my network set up to serve PXE clients. So I plug in a new box, set it to boot from the network, and I choose from a menu (I made) of choices to install things like CentOS 4 and Ubuntu 6.06.

With RH and derivatives, you can basically copy all the CDs you need into a directory, serve that directory up somewhere (I’ve got a web server running on the file server for this), and do the install entirely off your local network. I was completely unsuccessful trying this with Debian testing (Etch). I was basically successful in doing this with Ubuntu server 6.06, but it was a little funny: I had to tell the installer not to look to security.ubuntu.org for updates when installing, and I had to rewrite my sources.list once I was done (it pointed at my local mirror; these boxes are going out to clients, generally, where they can’t get at my local mirror).

So instead I decided to give an actual network install from the Internet a try. However, I still don’t want to download the same packages over and over again for every install; that’s wasteful of time and bandwidth. I could have used something like apt-proxy, but I wasn’t excited about getting that working on one of my CentOS or Fedora machines. Instead, I decided to try Squid.

Below are the important bits from squid.conf. I’m using Squid as packaged with CentOS 4.4, which is something like Squid version “2.5.” (I hope that “version” exists; I see more about 2.4 or 3.0… gcc 2.96 anyone?) Note that these were mostly derived from a couple pages I read: “Using Squid as an APT cache” and “apt-proxy – a staggering failure.”

# Cache packages up to 200MB in size.
maximum_object_size 200000 KB

# "LFUDA" is "least frequently used with dynamic aging."  It
# supposedly improves byte hit rate at the cost of request hit rate.
# Byte hit rate is more what we want; plus it makes sense to purge the
# least frequently used files first, I think.
cache_replacement_policy heap LFUDA

# Cache directory size defaults to 100MB, which probably isn't big
# enough.  I increased the size to 1GB (which might be overkill,
# depending on what I use Squid for).
cache_dir ufs /var/spool/squid 1000 16 256

# The last three lines are defaults, the rest are mine.
# Keep debs and rpms around for one year.  Technically, I think you
# might end up with objects hanging around only for the duration given
# by "object age" (now - last modified) unless that's more than a year
# See http://tinyurl.com/y2g2c3 (Squid FAQ, Inner Workings, how does
# Squid decide when to refresh a cached object).
refresh_pattern \.(u?deb|rpm)$  525949  100%    525949
# Debian package lists expire after a day.
refresh_pattern (^|/)Packages.gz$ 1440  100%    1440
# The following rules are Squid defaults.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern .               0       20%     4320

In my testing thus far this has worked out great. I’ve even got a preseed file specified in my PXELINUX configuration that sets the proxy automatically. Now I just hope I do another Ubuntu net install within a year, so I can use all those cached files I have.

No Comments

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS