<?xml version="1.0" encoding="UTF-8"?>
<snippet>
  <account-id type="integer">3</account-id>
  <body>Once you've bought a dual or quad Xeon and started to experiment with virtualization you will soon want to create your local mirror to make installs lightning fast. This is a step-by-step how i did it.

First create the Xen that will be our mirror server. The size requirements can be found here: &quot;Debian mirror sizes&quot;:http://www.debian.org/mirror/size The combined size of amd64 architecture and architecture independent files was 39Gb on 1.9.2007. So I made the image 50Gb big. Remember to change this mirror to a location near you.
&lt;code&gt;
xen-create-image --hostname=mirrors.aktagon.com \
--size=50Gb --swap=256Mb --ip=10.0.0.44 \
--netmask=255.255.255.0 --gateway=10.0.0.2 \
--force --dir=/work/vserver --memory=256Mb \
--arch=amd64 \
--kernel=/boot/vmlinuz-2.6.18-5-xen-amd64 \
--debootstrap --dist=etch \
--mirror= http://ftp.fi.debian.org/debian/\
--passwd
&lt;/code&gt;

Then ssh into your new Xen as root.
&lt;code&gt;
ssh -l root mirrors.aktagon.com
&lt;/code&gt;

Make base configurations for a fresh Xen.
&lt;code&gt;
apt-get update &amp;&amp; apt-get install locales console-data &amp;&amp; dpkg-reconfigure locales
&lt;/code&gt;

Then get the mirror synchronization script from Debian.
&lt;code&gt;
wget &quot;http://www.debian.org/mirror/anonftpsync&quot;
chmod a+x anonftpsync 
&lt;/code&gt;

Then install dependencies for anonftpsync script. Otherwise the script will fail with a &lt;i&gt;-bash: lockfile: command not found&lt;/i&gt; error.
&lt;code&gt;
apt-get install procmail
&lt;/code&gt;

Install nginx.
&lt;code&gt;
apt-get install nginx
&lt;/code&gt;

Configure anonftpsync with your favorite editor and change the lines below. These settings will setup a mirror _only_ for amd64 files. You could remove i386 from the excluded architectures, but then a 50Gb image won't fit all the files.
&lt;code&gt;
TO=/var/www/debian
RSYNC_HOST=ftp.fi.debian.org
RSYNC_DIR=debian
LOGDIR=/var/log/mirroring
ARCH_EXCLUDE=&quot;alpha arm hppa hurd-i386 i386 ia64 m68k mipsel mips powerpc s390 sh sparc source&quot;
&lt;/code&gt;

Make the log directory.
&lt;code&gt;
mkdir -p /var/log/mirroring
&lt;/code&gt;

Configure nginx by modifying /etc/nginx/nginx.conf with your favorite editor. Just add the autoindex line into server { location / { context
&lt;code&gt;
   # abbreviated start of file for clarity...
    server {
        listen       80;
        server_name  localhost;

        access_log  /var/log/nginx/localhost.access.log;

        location / {
            root   /var/www;
            # add the line below to allow directory listing
            autoindex  on;
            index  index.html index.htm;
        }
   # abbreviated end of file for clarity...
&lt;/code&gt;

Do the synchronizing. And wait... for a long while. On a 8/1Mbit cable the first synchronize took roughly 20 hours.
&lt;code&gt;
./anonftpsync
&lt;/code&gt;

Now modify your /etc/apt/sources.list on existing Xen images to use your local mirror. And remember to create new Xen images using your new mirror :) In the above case the URL is http://mirrors.aktagon.com/debian

NB: there is no public mirrors.aktagon.com available... sorry.</body>
  <comments-count type="integer">0</comments-count>
  <created-at type="datetime">2007-09-01T15:03:15+03:00</created-at>
  <id type="integer">69</id>
  <language-id type="integer">131</language-id>
  <rendered-body>&lt;p&gt;Once you&amp;#8217;ve bought a dual or quad Xeon and started to experiment with virtualization you will soon want to create your local mirror to make installs lightning fast. This is a step-by-step how i did it.&lt;/p&gt;


	&lt;p&gt;First create the Xen that will be our mirror server. The size requirements can be found here: &lt;a href=&quot;http://www.debian.org/mirror/size&quot;&gt;Debian mirror sizes&lt;/a&gt; The combined size of amd64 architecture and architecture independent files was 39Gb on 1.9.2007. So I made the image 50Gb big. Remember to change this mirror to a location near you.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; xen-create-image --hostname=mirrors.aktagon.com \
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; --size=50Gb --swap=256Mb --ip=10.0.0.44 \
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; --netmask=255.255.255.0 --gateway=10.0.0.2 \
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; --force --dir=/work/vserver --memory=256Mb \
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; --arch=amd64 \
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt; --kernel=/boot/vmlinuz-2.6.18-5-xen-amd64 \
&lt;span class=&quot;line-numbers&quot;&gt;   7 &lt;/span&gt; --debootstrap --dist=etch \
&lt;span class=&quot;line-numbers&quot;&gt;   8 &lt;/span&gt; --mirror= http://ftp.&lt;span class=&quot;Keyword&quot;&gt;fi&lt;/span&gt;.debian.org/debian/\
&lt;span class=&quot;line-numbers&quot;&gt;   9 &lt;/span&gt; --passwd
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Then ssh into your new Xen as root.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; ssh -l root mirrors.aktagon.com
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Make base configurations for a fresh Xen.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; apt-get update &lt;span class=&quot;Operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get install locales console-data &lt;span class=&quot;Operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; dpkg-reconfigure locales
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Then get the mirror synchronization script from Debian.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; wget &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;http://www.debian.org/mirror/anonftpsync&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; chmod a+x anonftpsync 
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Then install dependencies for anonftpsync script. Otherwise the script will fail with a &lt;i&gt;-bash: lockfile: command not found&lt;/i&gt; error.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; apt-get install procmail
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Install nginx.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; apt-get install nginx
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Configure anonftpsync with your favorite editor and change the lines below. These settings will setup a mirror &lt;em&gt;only&lt;/em&gt; for amd64 files. You could remove i386 from the excluded architectures, but then a 50Gb image won&amp;#8217;t fit all the files.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; TO=/var/www/debian
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; RSYNC_HOST=ftp.&lt;span class=&quot;Keyword&quot;&gt;fi&lt;/span&gt;.debian.org
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; RSYNC_DIR=debian
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; LOGDIR=/var/log/mirroring
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; ARCH_EXCLUDE=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;alpha arm hppa hurd-i386 i386 ia64 m68k mipsel mips powerpc s390 sh sparc source&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Make the log directory.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; mkdir -p /var/log/mirroring
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Configure nginx by modifying /etc/nginx/nginx.conf with your favorite editor. Just add the autoindex line into server { location / { context
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; abbreviated start of file for clarity...&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt;     server {
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt;         listen       80&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt;         server_name  localhost&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt;         access_log  /var/log/nginx/localhost.access.log&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   7 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;   8 &lt;/span&gt;         location / {
&lt;span class=&quot;line-numbers&quot;&gt;   9 &lt;/span&gt;             root   /var/www&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  10 &lt;/span&gt;             &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; add the line below to allow directory listing&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  11 &lt;/span&gt;             autoindex  on&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  12 &lt;/span&gt;             index  index.html index.htm&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  13 &lt;/span&gt;         }
&lt;span class=&quot;line-numbers&quot;&gt;  14 &lt;/span&gt;    &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; abbreviated end of file for clarity...&lt;/span&gt;
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Do the synchronizing. And wait&amp;#8230; for a long while. On a 8/1Mbit cable the first synchronize took roughly 20 hours.
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; ./anonftpsync
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Now modify your /etc/apt/sources.list on existing Xen images to use your local mirror. And remember to create new Xen images using your new mirror :) In the above case the  URL  is http://mirrors.aktagon.com/debian&lt;/p&gt;


	&lt;p&gt;NB: there is no public mirrors.aktagon.com available&amp;#8230; sorry.&lt;/p&gt;</rendered-body>
  <title>Creating a local Debian mirror for your Xen servers</title>
  <updated-at type="datetime">2008-07-08T22:02:19+03:00</updated-at>
</snippet>
