Begin by determining where you want your repositories to reside. You'll need plenty of drive space. Just as an example I'm mirroring Ubuntu 10.04 Lucid Lynx; 32 bit, packages only - no source code, all repositories and I'm using almost 40 gigs of space.
I'm using my mirror as the example for this tutorial and assuming your mirror will be used internally, not offered as an official mirror.
Start by installing apt-mirror and apache2:
System – Administration – Synaptic Package Manager.
Searching for apt-mirror then apache2 will give you the packages you need.
If you prefer to install using the terminal:
Code:
apt-get install apt-mirror apache2
Back up the configuration files:
Code:
sudo cp /etc/apt/mirror.list /etc/apt/mirror.list.orig
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
sudo cp /etc/cron/apt-mirror /etc/cron/apt-mirror.orig
sudo cp /var/spool/apt-mirror/var/postmirror.sh /var/spool/apt-mirror/var/postmirror.sh.orig
This can also be done without the terminal by opening each file in your chosen text editor (gedit for example) and choosing “save as” to place the backup copy in your home folder.
Now edit the files. The examples use nano, but gedit can also be used by invoking it within a terminal using gksudo.
Starting with mirror.list:
Code:
sudo nano /etc/atp/mirror.list
The config section of the file should not require any editing.
For the most part, the repositories section should be okay with its default entries as well. You might want to add the partner repository by adding this line:
Code:
deb http://archive.canonical.com/ubuntu lucid partner
You might also want to pull your security updates from security.ubuntu.com which would require this modification:
Code:
deb http://security.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
You can also remove or comment out the lines dealing with source code if you don't expect to need or use them. You can always add repositories later if you want. The time it takes to populate your mirror after adding something is less than the initial population of your mirror, so you can start with the minimum and add more later as the need arises.
Add a couple of lines to the “clean” section to clean up the extra repositories if you added or modified them as above:
Code:
clean http://archive.ubuntu.com/ubuntu
clean http://security.ubuntu.com/ubuntu
clean http://archive.canonical.com/ubuntu
Now you can run apt-mirror for the first time. You might want to wait on this step since it will take a while for your mirror to build, overnight for example. Also note that apt-mirror should be run as the user apt-mirror.
Code:
sudo su apt-mirror
apt-mirror
You'll see it working, but it will appear slow.
Once the mirror is populated, link the repository to the web server:
Code:
sudo ln -s /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu /var/www/ubuntu
sudo ln -s /var/spool/apt-mirror/mirror/security.ubuntu.com/ubuntu /var/www/security
sudo ln -s /var/spool/apt-mirror/mirror/archive.canonical.com/ubuntu/ var/www/canonical
NOTE: Only the first entry is necessary if you don't add or modify repositories.
Now edit postmirror.sh to invoke the clean script:
Code:
sudo nano /var/spool/apt-mirror/var/postmirror.sh
Add this line:
Code:
/var/spool/apt-mirror/var/clean.sh
Then make both scripts executable:
Code:
sudo chmod u+x /var/spool/apt-mirror/var/clean.sh
sudo chmod u+x /var/spool/apt-mirror/var/postmirror.sh
Finally, make apt-mirror an automated task:
Code:
sudo nano /etc/cron.d/apt-mirror
and remove the comment from the last line.
Moving to the client side:
Edit the sources.list file that will be used to access the mirror.
Code:
sudo nano /etc/apt/sources.list
The example below assumes using the mirror from the computer that hosts it. Using it from other computers on the network simply requires changing the IP address from 127.0.0.1 to whatever IP address is assigned to the mirror host.
Code:
deb http://127.0.0.1/ubuntu lucid main restricted universe multiverse
deb http://127.0.0.1/ubuntu lucid-updates main restricted universe multiverse
deb http://127.0.0.1/ubuntu lucid-backports main restricted universe multiverse
deb http://127.0.0.1/ubuntu lucid-proposed main restricted universe multiverse
deb http://127.0.0.1/security lucid-security main restricted universe multiverse
deb http://127.0.0.1/canonical lucid partner
On a side note, I've seen it recommended a couple of places that you pull your security updates from their original source rather than a mirror. If you choose to do that you want to leave this line for lucid-security unchanged:
Code:
deb http://security.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
__________________