Setup local mirror for Debian softwares repository
To save network bandwidth, we want to setup a local Debian software repository so that all local Debian hosts can update software via local network. The following steps show our approach using apt-mirror.
Install apt-mirror
apt-get install apt-mirror
Edit apt-mirror configuration file
vi /etc/apt/mirror.list
set nthreads 20
set _tilde 0
deb http://ftp.jp.debian.org/debian lenny main contrib non-free
deb-src http://ftp.jp.debian.org/debian lenny main contrib non-free
# indicate which can be clean to free local disk space
clean http://ftp.jp.debian.org/debian
Perform the mirroring
apt-mirror /etc/apt/mirror.list
After apt-mirror download all packages from remote server, we can run the clean up script to free some disk space
/bin/bash /var/spool/apt-mirror/var/clean.sh
We want to make apt-mirror automatically update new changes from remote server
vi /etc/cron.d/apt-mirror
#
# Regular cron jobs for the apt-mirror package
#
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
To make our local mirror accessable via HTTP
ln -s /var/spool/apt-mirror/mirror/ftp.jp.debian.org/debian /var/www/debian
Now, change local workstation software souce to use local mirror
vi /etc/apt/sources.list
# use our own local repository for lenny
deb http://192.168.1.1/debian/ lenny main contrib non-free
deb-src http://192.168.1.1/debian/ lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib
deb-src http://security.debian.org/ lenny/updates main contrib
If you encounter fetch package error while apt-get update on client, make sure there is no proxy setting in /etc/apt/apt.conf
On some clients, we recieved the following error,
W: GPG error: http://192.168.1.1 lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9AA38DCD55BE302B
W: There is no public key available for the following key IDs:
9AA38DCD55BE302B
W: You may want to run apt-get update to correct these problems
You can either solve this problem by adding the missing key into your keyring,
gpg --keyserver hkp://subkeys.pgp.net --recv-key 9AA38DCD55BE302B
gpg --export --armor F120156012B83718 | sudo apt-key add -
Or ignor the warning and force apt-get to upgrade,
apt-get -y --force-yes upgrade
