2009-07-27

Debian Mirror Howto

Today I will show you how to setup your own Debian repository.

Step 1: Install the apt-mirror package
# aptitude install apt-mirror

Step 2: Edit the configuration file /etc/apt/mirror.list

set base_path /var/spool/apt-mirror
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var

set defaultarch i386
set _tilde 0

# lenny's section
deb http://ftp.debian.org/debian lenny main contrib non-free
deb-amd64 http://ftp.debian.org/debian lenny main contrib non-free
deb-src http://ftp.debian.org/debian lenny main contrib non-free

# Cleaning section
clean http://ftp.de.debian.org/

skip-clean http://ftp.debian.org/doc/
skip-clean http://ftp.debian.org/tools/
skip-clean http://ftp.debian.org/debian-cd/
skip-clean http://ftp.debian.org/debian-minicd/
skip-clean http://ftp.debian.org/debian/dists/lenny/main/installer-i386/
skip-clean http://ftp.debian.org/debian/doc/
skip-clean http://ftp.debian.org/debian/tools/
skip-clean http://ftp.debian.org/debian/project/

Step 3: Install a cron job for regular mirror updates

For this create the file /etc/cron.d/apt-mirror:

#
# Regular cron jobs for the apt-mirror package
#
0 5 * * * apt-mirror /usr/bin/apt-mirror \
> /var/spool/apt-mirror/var/cron.log

Step 4: Add some lines to your Apache configuration

Alias /mirror-debian/ /var/www/mirror-debian/
<directory>
AllowOverride None
Options -MultiViews FollowSymLinks Indexes
Order allow,deny
Allow from all
</directory>

Step 5: Start initial download

# su - apt-mirror -c apt-mirror

Step 6: Configure your clients to use the new repository

deb http://your.hostname/mirror-debian/debian/ lenny main contrib non-free
deb-src http://your.hostname/mirror-debian/debian/ lenny main contrib non-free

deb http://security.debian.org/ lenny/updates main contrib non-free
deb-src http://security.debian.org/ lenny/updates main contrib non-free

Thats all!