Who says procrastination can make a person dull?

Setting Up Apt-Mirror to Download Ubuntu Repositories and Create Local Repositories for Use in a Local Network

Yeah, I'm getting my Ubuntu geek on now.

(Methinks I like the meerkat/timon better. But I'm partial to mammals. I loove the karmic koala the best! But i'm digressing..)

On to the tutorial-slash-note-to-myself:


Open Terminal, type:

sudo apt-get update
(this I think updates packages already installed on the system)

Type:
sudo apt-get install apt-mirror
(downloads and installs the apt-mirror package)

Type:
sudo apt-get install apache2
(downlaods and installs the apache2 package you need to serve as local server)

Type:
sudo nano /etc/apt/mirror.list

This opens the mirror.list file in a text editor called Nano right in the Terminal console. You can edit the mirror.list according to your needs. Note: You will need to uncomment (remove the #) on the lines you are going to edit, otherwise nothing will happen.

I've set up mine as the ff:

############# config ##################
#
set base_path    /MYDIR
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  i386
set postmirror_script $var_path/postmirror.sh
set run_postmirror 0
set nthreads     20
set _tilde 0
#set limit_rate 2.5k
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu natty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu natty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu natty-updates main restricted universe multiverse
deb http://archive.canonical.com/ubuntu natty partner
deb http://extras.ubuntu.com/ubuntu natty main
#deb http://archive.ubuntu.com/ubuntu natty-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu natty-backports main restricted universe multiverse

clean http://archive.ubuntu.com/ubuntu
clean http://archive.canonical.com
clean http://extras.ubuntu.com

NOTE:
 mirror://mirrors.ubuntu.com/mirrors.txt ---> use this to identify closest mirror

Some parameters:

    base_path: The place where are the downloaded packages go. NOTE: make sure you have write permissions to this directory
    mirror_path,skel_path,var_path,cleanscript,postmirror_script,run_postmirror,_tilde: Better leave them as they are.
    defaultarch: When you specify "deb <deb-url>" it'll fetch the URL of this type, or you can explicitly specify which architecture packages to pick up by specifying it as "deb-i386 <deb-url>"
    nthreads: The number of threads of wget that have to be launched for fetching the mirror contents
    limit_rate: This variable can be set to limit the download rate of the wget but this is per thread. So it boils down to (20 Threads)*2.5KBps = 50 KBps (Notice the 'B' it's for bytes).
    I just picked up the deb URL's from my file "/etc/apt/sources.list".
    I skipped the "deb-src" url's because I wouldn't be needing the sources and it'll just eat up my space. It all depends on the need of  the mirror if you need 'em just include them in the package.
    deb-urls: These are of the form "deb http://archive.ubuntu.com/ubuntu maverick-updates main restricted universe multiverse". Replace maverick with the codename that you want to mirror, maverick is the codename for Ubuntu 10.10. You can find out which version you are using by the command "lsb_release -a". If you just need the codename use "lsb_release -c". You can mirror any number of archives.

After souping up the mirror.list file, type:

^X

You will be prompted to save the file, click Yes, and further prompted where to save the new file, just hit [Enter] to overwrite the existing file.

If you've changed the base directory, type:

Having changed the base_directory, I need to create some directories under /spare like so:

sudo mkdir /MYDIR/mirror
sudo mkdir /MYDIR/skel
sudo mkdir /MYDIR/var

You're ready to mirror! Type

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

Note the "&" is so that I can run apt-mirror detached from the terminal.

Be ready to devote time - hours, or even several days, depending on your internet connection. In case you want to stop it and restart it from there the is no problem as it continues from there. So you can just run it when no one is using the connection.

If you're done - congratulations! You're halfway through. To clean up unwanted files, open Terminal and Type:
sudo /var/spool/apt-mirror/var/clean.sh

If you want all your packages to be updated everyday you will need to edit the cron file of the apt-mirror package:

gksudo gedit /etc/cron.d/apt-mirror
*or* sudo nano /etc/cron.d/apt-mirror

just uncomment the # from the last line and it will be updated every day at 4:00 AM you can edit and also change the timing and interval.

Useful sources:

http://www.danbishop.org/2011/03/11/create-your-own-local-mirror-of-the-ubuntu-repositories/
http://www.developerstation.org/2011/05/creating-local-ubuntu-mirror-using-apt.html
http://www.ajatus.in/2011/02/set-up-your-own-ubuntu-repository-using-apt-mirror/
http://nwlinux.com/configure-an-ubuntu-repo-mirror/
https://apps.education.ucsb.edu/wiki/Set_up_apt-mirror

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger