The Tiny Internet Project, Part III

Deploy a Linux Repository Mirror

You have two choices when it comes to deploying the Ubuntu repository: clone your new VM template and resize its 30GB virtual disk, or create an all-new VM with a larger disk. I explain the latter here.

Start by creating a new VM from the Ubuntu .iso file you used to create your template VM. This time, give the machine a virtual disk that's at least 200GB. Boot the machine and step through the server installation process as before, making sure to give the machine the hostname "mirror" and an IP address of Use the same user name and password you set on your template, and install only OpenSSH from the application list.

Follow the procedure for adding a second NIC, and be sure to leave the /etc/apt/sources.list unchanged for now. You'll need it to point to the default external Ubuntu repository.

Install apt-mirror

With the machine set with access to both your tiny internet and the public internet, install apt-mirror and the web server that will serve up packages:

$ sudo apt-get install apt-mirror apache2

The core of the apt-mirror configuration is the list of repository URLs. Make a backup of the default file and edit the original:

$ sudo cp /etc/apt/mirror.list /etc/apt/mirror.list.bak
$ sudo vi /etc/apt/mirror.list

Leave the config section at the top as is, and don't change the first three deb listings. However, to save disk space, remove all the deb-src entries and replace them with the 32-bit repositories. Your entries should look like this:

deb trusty main restricted
 ↪universe multiverse
deb trusty-security main
 ↪restricted universe multiverse
deb trusty-updates main
 ↪restricted universe multiverse

deb-i386 trusty main
 ↪restricted universe multiverse
deb-i386 trusty-security main
 ↪restricted universe multiverse
deb-i386 trusty-updates main
 ↪restricted universe multiverse


Save the file and start apt-mirror with your edited mirror.list. Depending on your internet connection, this likely will take many hours. You'll get a hint of just how long when it tells you how many gigabytes will be downloaded. Be patient:

$ sudo apt-mirror /etc/apt/mirror.list

Continue your work during this download by opening another shell into the server. You can configure apache2 while apt-mirror is doing its thing by creating a symbolic link from the apt-mirror repository to the web directory that was created automatically when you installed apache2.

If you haven't already, test to see that the web server is up by pointing your browser to

If it works, create a new directory at the root of the web server:

$ sudo mkdir /var/www/html/ubuntu

Create a symbolic link from the directory where apt-mirror stores the packages to the new directory:

$ sudo ln -s /var/spool/apt-mirror/mirror/
↪ubuntu/pool/ /var/www/html/ubuntu

Test it by pointing your browser to If you see a list of directories, you're all set. Any VMs built with the local sources.list will be able to download packages from this local server once apt-mirror completes. (See the Resources section for more information.)

Figure 14. Installing apt-mirror


John S. Tonello is Director of IT for NYSERNet, Inc., in Syracuse, New York. He's been a Linux user and enthusiast since he installed his first Slackware system from diskette 20 years ago. You can follow him @johntonello.