How to mirror the entire Ubuntu software repository locally and to create your own Ubuntu Repository DVDs
Unlike proprietary operating systems that comes up with a rudimentary set of applications, Ubuntu and GNU/Linux in general has thousands of freely available Free Software applications available for installation directly from the Internet. These applications are usually available from software archives referred to as repositories. The official Ubuntu repositories contain more than 30000 applications. Having the Ubuntu repositories on DVD can be useful for those users who don't have access to the Internet or has only limited connectivity from the machine where they have their Ubuntu installed but have access from somewhere else to download the repository. Here is a step by step instruction on how to download the complete Ubuntu repositories and build your own set of Ubuntu Repository DVDs. For those who would like to get it done the easy way you can buy a set of Ubuntu Repository DVDs via our RequestCD program
First you have to build a local repository mirror using apt-mirror. apt-mirror is a tool for creating mirror of a Debian archive. Open Terminal (Alt+Ctrl+T) and paste the following command to install apt-mirror.
sudo apt-get install apt-mirror
Make a directory to store the repository which we are going to download from the Internet.
Now edit the apt-mirror config file to make some changes.
set the base path to where you would like to download the repository archive.
############# config ##################
# CORRECT THE FOLLOWING PATH TO POINT TO THE FOLDER YOU CREATED
set base_path /home/your-username/UbuntuRepos
# 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 20
set _tilde 0
Comment (put # infront of ) the following lines that we doesn't really need.
deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
Save and close the file
Then run the apt-mirror to start the repository download.
You might also want to enable the crontab entry in /etc/apt/mirror.list that will allow you to run apt-mirror daily. apt-mirror will scan the online archive and will download the full repository to your local machine. For Ubuntu 12.04, it will download around 47GB of packages each for the i386 and amd64 versions.
After all the downloads are completed, we will need to seperate archives into DVD sized directories. A tool called debpartial will do this.
sudo apt-get install debpartial
debpartial is a command-line tool to generate partial Debian packages archives mirrors. It is designed to work (in particular) in Custom Debian Distributions framework, as an aid to create customization of debian systems.
Now create the directory where the volume will reside.
Use the following command to divide the downloaded archives into DVD sized directories.
debpartial --nosource --section=main,restricted,universe,multiverse --dist=precise,precise-security,precise-updates --size=DVD ~/UbuntuRepos ~/ubuntu-DVDs
where ~/UbuntuRepos is the source of the repostory we just have downloaded. You really need to find out how many DVDs we need to create, paste the following command and hit Enter to find it out. Remember that there are no spaces after commas in the above command line.
ls -l ~/ubuntu-DVDs
If the last folder is 10 then you need to create 11 DVDs. And if the last folder is 11 then it will be 12 DVDs. Now we have to put the packages into the directories debpartial has just created. A script called debcopy which only works with ruby will help to copy the packages into directories. Click here to download the debcopy script and save it in home folder.
sudo apt-get install ruby
We want to make soft links from the complete repository instead of copying the packages, we can call debcopy with the option -l.
ruby ~/debcopy -l ~/UbuntuRepos ~/ubuntu-DVDs/0
ruby ~/debcopy -l ~/UbuntuRepos ~/ubuntu-DVDs/1
ruby ~/debcopy -l ~/UbuntuRepos ~/ubuntu-DVDs/2
ruby ~/debcopy -l ~/UbuntuRepos ~/ubuntu-DVDs/N (replace the letter N with the last directory)
Well, you've got enough data to create DVDs. Make a folder where you need to store the iso images.
change the present working directory to ~/Ubuntu-DVD-iso
Let's start creating the iso.
mkisofs -f -J -r -V "Ubuntu 12.04 1/12" -o ubuntu-12.04-$(date -I)-complete-i386-dvd1.iso ~/ubuntu-DVDs/0
mkisofs -f -J -r -V "Ubuntu 12.04 2/12" -o ubuntu-12.04-$(date -I)-complete-i386-dvd2.iso ~/ubuntu-DVDs/1
mkisofs -f -J -r -V "Ubuntu 12.04 3/12" -o ubuntu-12.04-$(date -I)-complete-i386-dvd3.iso ~/ubuntu-DVDs/2
mkisofs -f -J -r -V "Ubuntu 12.04 12/12" -o ubuntu-12.04-$(date -I)-complete-i386-dvd12.iso ~/ubuntu-DVDs/11
Done! Now you can burn these isos into DVDs and use it as Ubuntu Repository.
There are two different ways to add the DVDs to the repository list.
Ubuntu 12.04 comes with a bug that it will not mount the cdrom on proper path. So you need to manually mount the cdrom everytime to make it work with repository DVDs. Check out the solution to the bug that prevents repository DVDs from being recognized in Ubuntu. Once you run the fix you can run the following command
sudo apt-cdrom add
You'll be prompted to name the DVD , give the name such as DVD1, DVD2, DVD3...etc. After all the DVDs are loaded, reload the system repository using following command.
sudo apt-get update
Now your system is ready to install any packages using Ubuntu Repository DVDs.
Via Synaptic Package manager
First Insert the repository DVD into cdrom drive. Open synaptic Package manager and goto Edit >> Add CD-ROM Now you'll be prompted to name the Disk. Name it like DVD1, DVD2 etc. Press the reload button to update the system repository. Then let's start install any packages from repository DVDs.