How to set up your own Debian Linux Mirror

Looking to build your own Debian Linux Mirror? Use your local hard drive or a network drive and share your mirror over a network or even on the internet. Having your our own Debian/Ubuntu Linux Mirror enables you to drastically speed up the process of installing packages or complete netbuilds on your single or networked Linux PC (s).

Using the following tutorial, the same method can be used for building a Ubuntu Mirror if desired.

Note: This process was tested using both Debian Etch and Lenny. If step 2 fails to find and install the apt-mirror package, you may need to add the following line to your /etc/apt/sources.list
deb http://apt-mirror.sourceforge.net/ apt-mirror/
How to create a local Debian Mirror:

  1. Open a terminal and type sudo su
  2. Type apt-get install apt-mirror apache2
  3. Type mv /etc/apt/mirror.list /etc/apt/backup-mirror.list
  4. Type gedit /etc/apt/mirror.list and add the following for a Debian Etch repository (Replace Etch with Lenny for a Lenny Mirror) then save the file:
  5. # apt-mirror configuration file
    ##
    ## The default configuration options (uncomment and change to override)
    ##
    #
    # 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
    # set nthreads 20
    #
    set _tilde 0
    ##
    ## Example sources
    ### Etch's section
    deb http://ftp.us.debian.org/debian etch main contrib non-free
    deb-src http://ftp.us.debian.org/debian etch main contrib non-freedeb http://security.debian.org/debian-security etch/updates main contrib non-free
    deb-src http://security.debian.org/debian-security etch/updates main contrib non-freedeb http://ftp.us.debian.org/debian etch main/debian-installer##
    ## Cleaner configuration example
    ##
    #
    # set cleanscript $var_path/clean.sh
    ## Cleaning section
    clean http://security.debian.org/
    clean http://ftp.us.debian.org/

  6. Type su - apt-mirror -c apt-mirror (to start the Mirror creation process)
  7. The process will take many hours, so it's best to start this process when you plan to be away from the PC for some time.
    (Your Debian Mirrors will be stored in subdirectories located at /var/spool/apt-mirror/mirror/)

Make your Mirror available via HTTP (localhost or Network IP):

To access your Mirror on a network, replace localhost in step 4 with the IP address of the PC hosting the Mirror

  1. From the terminal type ln -s /var/spool/apt-mirror/mirror/ftp.us.debian.org/debian /var/www/debian
  2. Type ln -s /var/spool/apt-mirror/mirror/security.debian.org/debian-security /var/www/debian-security
  3. Type mv /etc/apt/sources.list /etc/apt/backup-sources.list (to backup your original list)
  4. Type gedit /etc/apt/sources.list and add the following deb sources, then save the file:
    deb http://localhost/debian etch main contrib non-free
    deb-src http://localhost/debian etch main contrib non-free
    deb http://localhost/debian-security etch/updates main contrib non-free
    deb-src http://localhost/debian-security etch/updates main contrib non-free
  5. Type apt-get update and enjoy having the ability to install Debian or packages from your own Debian Repository Mirror
Disclaimer