2011-12-10

How to set up a local Debian mirror using 'apt-mirror'

TRANSFERRED.

You know the story: you're administering a slew of Debian machines and the Internet connection is way too slow. Every time you run "apt-get update && apt-get upgrade" on another machine, it's excruciating. You need a local mirror. Your very own, private Debian mirror.

My first searches took me to this page: Setting up a Debian archive mirror

However, that was the wrong page, because I didn't want to mirror the entire Debian archive. I only wanted to mirror amd64 and i386 binary packages in "wheezy" (main, contrib, nonfree).

Eventually I found apt-mirror. It's a Perl script. If it's installed (the aptly-named package is "apt-mirror"), it's located at /usr/bin/apt-mirror.

To get it to work meaningfully, you have to edit the file "/etc/apt/mirror.list". Here's mine:
############# config ##################
#
set base_path    /home/apt-mirror
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch 
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     10
set _tilde 0
#
############# end config ##############

deb http://ftp.cz.debian.org/debian wheezy main contrib non-free
deb-src http://ftp.cz.debian.org/debian wheezy main contrib non-free
Pay special attention to the "set nthreads" directive, which stipulates how many copies of "wget" are going to run simulaneously. The default value was 20. I reduced it to 10 and I'm going to reduce it even more, because even 10 was too much for my system.

Another caveat: the default mirror location is "/var/spool/apt-mirror". However, on my system /var does not have enough disk space for a Debian mirror. So I changed the "base_path" variable to "/home/apt-mirror" so the pool gets saved on /home, which is on a partition that does have enough room.

No comments:

Post a Comment