This seemed like a pretty simple exercise:
- Install apt-mirror package
- Specify which repositories should be mirrored
- Download content from repositories (the long step)
- Serve mirrored directory via Apache or Lighttpd
- Tell all VMs to use local repository
Step one is the easiest, just run:
apt-get install apt-mirrorStep two requires to modify
/etc/apt/mirror.listfile to select specific repositories and perhaps choose ones geographically closer. Here's mine:
set nthreads 20 set _tilde 0 deb http://ca.archive.ubuntu.com/ubuntu hardy main restricted universe deb http://ca.archive.ubuntu.com/ubuntu hardy-updates main restricted universe deb http://ca.archive.ubuntu.com/ubuntu hardy-security main restricted universe clean http://ca.archive.ubuntu.com/ubuntuBased on some online recommendations I'm not mirroring
deb-srcpackages here or security updates.
In step three I'm supposed to run
su - apt-mirror -c apt-mirroras root to clone repositories listed in mirrors file. However, this is where I hit a bit of a snag...
My work's LAN is behind a firewall and we use http proxy (Squid) for Internet access. There's already a line in
/etc/apt/apt.confthat tells apt to use this proxy server:
Acquire::http::Proxy "http://my-proxy.lan:3128/";It works fine with
apt-mirrordoesn't seem to know or care about it.
Exporting environment variable as root doesn't do any good because command
is actually ran as apt-mirror user (that's what "
su - apt-mirror -c" is for). So to force apt-mirror to use proxy, I added this line to
http_proxy="http://my-proxy.lan:3128/"Probably not the best way to solve this, but it works.
Once the first sync is done we will have a copy of repository stored locally on this machine. It seems this step requires at least 25 GiB of free disk space per architecture type.
Step four is to allow other machines access our local repository. Just need to install Apache or lighttpd and make local mirror directory accessible over HTTP:
apt-get install lighttpd cd /var/www ln -s /var/spool/apt-mirror/mirror/ca.archive.ubuntu.com/ubuntu ubuntuNow local repository is visible at
Step five will take the most time, since I have to edit
/etc/apt/sources.listfile on every VM and add:
deb http://my-apt-mirror-host.lan/ubuntu hardy main restricted universe deb http://my-apt-mirror-host.lan/ubuntu hardy-updates main restricted universe deb http://my-apt-mirror-host.lan/ubuntu hardy-security main restricted universeI'm going to keep all lines with "
deb http://security.ubuntu.com/ubuntu" unchanged, since I'm not mirroring them. All the "
deb http://ca.archive.ubuntu.com/ubuntu" will be commented out.