Debian GNU/Linux local mirror setup

Setting up a local mirror of a Debian GNU/Linux release is very helpfull if you want to install, update and  maintain several machines/installations. A local mirror avoids multiple downloading of the same package thru the (slow) internet. A local mirror requires a single download of the packages from the internet and allows to distribute the packages thru your local network.

A local Debian GNU/Linux mirror requires the following setup:
- free space on your disk (up to 25GB for main, contrib and non-free of the i386 architecture without sources)
- an FTP-server running on the mirroring machine
- the package "debmirror" is required for easy mirroring

If you want to use your local mirror for Netinstall (e.g. via CD), you need in addition:
- an accessible preseed-config-file on the local mirror
- to give a bootparameter on the NetInstall-bootprompt which points to the preseed-config-file

Step1:

*     install the "debmirror" package
*     install the "proftp" package (or any other ftp-server of your choice)

Step2:

*    choose and create a subdirectory which will contain all the mirrored content (e.g. .../DebianMirror/...)
      this can be done as USER and does not require admin rights

Step3:
*    setup proftp via the file "/etc/proftpd/proftpd.cfg"
*    it is important to setup a anonymous login (user:ftp, group:nogroup) with the incoming directoy pointing to the mirror directory (e.g. .../DebianMirror/...)
*    a user with the name "ftp" should be added (if not already done automatically) and its home-directory should be the mirror directory
(e.g. .../DebianMirror/...)

Step4:

*   test the anonymous ftp-access from another computer via an ftp-prgramm with anonymouslogin
*   you should be able to login to the mirror directory
(e.g. .../DebianMirror/...) remotely

Step5:

* import the Debian archive keys via GPG: "gpg --import archive-key-5.0.asc"
*   List the keys: "gpg --list-keys"
*   Export the key (ID:55BE302B) to the trustedkeys.gpg file: "gpg --output ~/.gnupg/trustedkeys.gpg --export 55BE302B"
*   This is required since Debian Lenny (Debian Etch did not required this !)


Step6:
*  start the download of the files from another mirror with "debmirror"
    debmirror -a i386 -s main -s contrib -s non-free -h ftp2.de.debian.org -d testing /media/Daten_USB/DebianMirror/ --nosource --progress
    (e.g. architecture: i386 only / release:testing / packages: main, contrib, non-free / no sources / get it from ftp2.de.debian.org)
*  this can take a long time (depending on your internet connection)
 

Step7:
*  create a symbolic link with the name of the actual release pointing to the mirrored files in the subdirectory "/dists" (e.g. ".../DebianMirror/dists/ln -s testing squeeze)
    squeeze --> testing (squeeze points to testing)
*   if this symbolic link is not existent, the NetInstall from CD may fail, because Netinstall sometimes requires the release name (sarge, etch, lenny, squeeze ...) instead of the release state (        
    (stable,testing,unstable)

Step8:
*   add the new mirror ftp-server to the /etc/apt/sources.list of the computer which wants to get its updates from the local mirror
    deb ftp://192.168.2.1/ testing non-free contrib main
*   try to update from the new mirror (with apt or synaptic)

Step9:
*    create the preceed config-file for NetInstall with the following content:
    # Give the following line as Bootparameter on Netinstall HWE, 22.02.2009:
    # preseed/url=ftp://192.168.2.33/preseed/preseed.cfg
    # By default the installer requires that repositories be authenticated
    # using a known gpg key. This setting can be used to disable that
    # authentication. Warning: Insecure, not recommended.
    d-i debian-installer/allow_unauthenticated string true

*   put this file into a subdirectory (e.g. .../DebianMIrror/preceed/preceed.config)
*   the preceed config files tells the debian installer toe take the packages unauthenticated (which is not recommended for untrusted ftp-servers)

Step10:
*   When doing a NetInstall, add the following boot-parameter to the bootprompt, when starting the debian-installer (in expert mode):
   
preseed/url=ftp://192.168.2.33/preseed/preseed.cfg
*   during the installation you can select the debianmirror to install from (make sure the symbolic link, as described above, is set correctly; e.g. squeeze ---> testing)