The Goal.
If you want to set up a local Ubuntu mirror, you can download its contents from an online repository—as I documented in an earlier post in this thread. You will then, however, have to download a huge amount of data—which may be impractical to you.
To bypass the “Big Download,” you may prefer to obtain a set of Ubuntu Repository DVDs, and use these to initialise your local mirror instead. Once your local mirror is up and running, you can then keep it up-to-date by periodically rerunning the “debmirror” command.
Purchasing Ubuntu Repository DVDs.
In the initial post of this thread, BobSongs listed some of the vendors from which you can purchase a set of Ubuntu Repository DVDs.
To order your copy, first decide which Ubuntu release you want—e.g., Ubuntu 9.04 (the “Jaunty Jackalope”). The vendor may append a second set of numbers to the release, to identify when the DVD contents were brought up-to-date—e.g., “Ubuntu 9.04-9.06” identifies the Ubuntu 9.04 release, brought up-to-date as of June, 2009.
Also, decide for which CPU architecture you want to obtain the repository DVDs: i386 (i.e., the 32-bit version), or amd64 (i.e., the 64-bit version)—or, perhaps, both.
Note:
Before you order your set of discs, ensure that your computer meets the system requirements specified by the vendor—you may, for example, need a DVD drive that can read Dual Layer DVD±R media.
Once you have placed your order, you will simply have to wait until the discs are delivered. (In my case, the vendor announced that it would take some 10 working days for my order to arrive, but I actually received it after only five or six working days... Nice!)
Loading your Local Mirror from the DVDs.
Once you receive the set of discs, you can set up your local mirror, and load it from the discs. First, you will need to create a directory for your mirror—e.g., “~/UbuntuRepos”:
Code:
mkdir ~/UbuntuRepos
Next, insert the first DVD into your drive, and wait until your system mounts it (and, most likely, opens a file browser window for it). The DVD should contain two directories (or “folders,” in GUI-Speak):
- “dists”—which can help you identify the values that you will have to specify for the “--dist” and “--section” parameters on the “debmirror” command, later on;
- “pool”—which contains the actual software packages that you will have to copy into your local mirror.
To list the contents of the “dists” directory, you can execute the following command:
Code:
ls /media/cdrom/dists
Note:
If your computer has more than one CD and/or DVD drive (or if the system doesn’t make the “cdrom” synonym available for some reason), then you may have to replace the “cdrom” device designation with some other name; you can identify the appropriate device name on the title bar of the file browser window that displays the DVD contents.
Alternatively, you can, of course, open the “dists” folder from the graphical desktop environment.
As an example, the “dists” directory may contain the following four subdirectories:
- jaunty
- jaunty-backports
- jaunty-security
- jaunty-updates
These are the values that you will have to use for the “--dist” parameter when you run the “debmirror” command—so, e.g.:
Code:
--dist=jaunty,jaunty-backports,jaunty-security,jaunty-updates
Each of these subdirectories will contain another set of subdirectories—e.g.:
- main
- multiverse
- restricted
- universe
From this list, you can construct the “--section” parameter for the “debmirror” command—e.g.:
Code:
--section=main,multiverse,restricted,universe
Finally, in each of these subdirectories, you will find yet another subdirectory, which identifies the CPU architecture to which the disc set applies—either, “binary-i386” or “binary-amd64,” for the 32-bit or the 64-bit architecture, respectively. This directory corresponds to the “--arch” parameter for the “debmirror” command:
or:
or even (if you load the disc sets for both architectures into your local mirror):
Note:
You will not, at this point, have to actually use these parameter values. Just note them down, so you have them available when you need them, later on.
Now, run the following command to copy the contents of the “pool” directory into your local mirror:
Code:
cp --recursive --verbose /media/cdrom/pool ~/UbuntuRepos
Afterwards, you will have to update the permission flags on the directories and files that you copied to your harddisk; otherwise, they will remain read-only, and you will not be able to further update your local mirror (e.g., to copy the contents of the remaining discs into it). Just run the following command:
Code:
chmod --recursive --verbose u+w ~/UbuntuRepos/pool
Next, insert each of the remaining DVDs in turn, and repeat the copy and “chmod” commands for each of them:
Code:
cp --recursive --verbose /media/cdrom/pool ~/UbuntuRepos
chmod --recursive --verbose u+w ~/UbuntuRepos/pool
Note:
You may want to verify if the “dists” directory on each of the DVDs contains any subdirectories that aren’t present on any earlier disc. If there are any, then you should add them to the “--dist” parameter for the “debmirror” command, as discussed above.
Theoretically, you could even encounter new subdirectories that should be added to the “--section” parameter for the “debmirror” command—though, in practice, I believe that won’t be very likely to happen.
Adding Packages for a Second CPU Architecture to your Local Mirror.
After you copy all packages for one CPU architecture (e.g.,
“i386”) to your local mirror, you may want to add the packages for the other architecture (e.g.,
“amd64”) to it as well. To this end, you can just repeat the copy and
“chmod” commands for each of the DVDs for the second architecture. Some packages are common to both architectures, however; you may, therefore, want to avoid recopying these common packages, to help speed up this operation a little. In other words, you may want to add the
“--update” option to the copy command, to ensure that only new
(or newer versions of existing) files will be copied over:
Code:
cp --recursive --update --verbose /media/cdrom/pool ~/UbuntuRepos
chmod --recursive --verbose u+w ~/UbuntuRepos/pool
Note:
Some DVD drives may become somewhat unstable, and report read errors when they are heavily used for relatively long periods of time. If you experience DVD read errors on, e.g., the third or fourth DVD that you are trying to copy in a single session, you may want to power down your computer for a few hours, and then retry. Only if you then keep getting DVD read errors should you assume that there is a problem with the disc.
Also, DVD read errors are almost guaranteed to occur if you perform these steps on a battery-powered laptop when the battery is running low.
Creating the Keyring for your Local Mirror.
As I explained in my earlier post, you will have to create a particular keyring, to allow “debmirror” to validate the integrity of your local mirror. Just run the following command (if you haven’t already done so on an earlier occasion):
Code:
gpg --no-default-keyring --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export \
| gpg --no-default-keyring --keyring trustedkeys.gpg --import
OPTIONAL: Taking “debmirror” for a Test Drive.
You are now ready to run “debmirror” for the first time, to load the control files that will allow you to install software packages from your local mirror. In addition, “debmirror” will download any updates that may have become available since the DVDs were produced, and it will delete any obsoleted packages.
Since “debmirror” rather aggressively deletes from your local mirror any files that are not present in the online mirror with which it synchronises, large portions of your local mirror may get zapped if you make an error in any of its arguments. Therefore, you may prefer to take it for a test drive before you actually let it manipulate your local mirror. To request such a test drive, you can use the “--dry-run” parameter on the “debmirror” command, as follows:
Code:
debmirror --dry-run --nosource --md5sums --passive \
--host=online-repository-host --root=ubuntu --method=http --progress \
--dist=dist-list --section=section-list --arch=arch-list \
~/UbuntuRepos
where:
- “online-repository-host” represents the online mirror with which you want to synchronise your local mirror—e.g., the generic “archive.ubuntu.com” or your national mirror (which, in my case, would be “be.archive.ubuntu.com”).
- “dist-list” represents the “--dist” value, as discussed above—e.g.:
Code:
jaunty,jaunty-backports,jaunty-security,jaunty-updates
- “section-list” represents the “--section” value, also discussed above—e.g.:
Code:
main,multiverse,restricted,universe
- “arch-list” represents the CPU architecture(s) to which your local mirror applies—e.g., “i386” or “amd64” (or both: “i386,amd64”).
The actual “debmirror” command, with all values substituted into it, may, thus, look like this:
Code:
debmirror --dry-run --nosource --md5sums --passive \
--host=archive.ubuntu.com --root=ubuntu --method=http --progress \
--dist=jaunty,jaunty-backports,jaunty-security,jaunty-updates \
--section=main,multiverse,restricted,universe --arch=i386,amd64 \
~/UbuntuRepos
As part of its output, the “debmirror” command will list the updated packages that have become available, and that would be loaded into your local mirror if this were a real run—e.g.:
Code:
Getting: pool/main/f/firefox-3.0/abrowser-3.0-branding_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_amd64.deb... ok
Getting: pool/main/f/firefox-3.0/abrowser-3.0-branding_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_i386.deb... ok
Getting: pool/main/f/firefox-3.0/abrowser_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-branding_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_amd64.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-branding_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_i386.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-dev_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_amd64.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-dev_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_i386.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-gnome-support_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_amd64.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0-gnome-support_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_i386.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_amd64.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-3.0_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_i386.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-dev_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-gnome-support_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-granparadiso-dev_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Getting: pool/main/f/firefox-3.0/firefox-trunk-dev_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Getting: pool/main/f/firefox-3.0/firefox_3.0.11+build2+nobinonly-0ubuntu0.9.04.1_all.deb... ok
Furthermore, it will list the files that it considers obsoleted, and that it would delete—e.g.:
Code:
deleting pool/main/f/firefox-3.0/firefox_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-branding_3.0.10+nobinonly-0ubuntu0.9.04.1_i386.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-gnome-support_3.0.10+nobinonly-0ubuntu0.9.04.1_i386.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-gnome-support_3.0.10+nobinonly-0ubuntu0.9.04.1_amd64.deb
deleting pool/main/f/firefox-3.0/firefox-gnome-support_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/firefox-trunk-dev_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/firefox-3.0_3.0.10+nobinonly-0ubuntu0.9.04.1_amd64.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-dev_3.0.10+nobinonly-0ubuntu0.9.04.1_amd64.deb
deleting pool/main/f/firefox-3.0/abrowser_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/abrowser-3.0-branding_3.0.10+nobinonly-0ubuntu0.9.04.1_i386.deb
deleting pool/main/f/firefox-3.0/firefox-3.0_3.0.10+nobinonly-0ubuntu0.9.04.1_i386.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-branding_3.0.10+nobinonly-0ubuntu0.9.04.1_amd64.deb
deleting pool/main/f/firefox-3.0/firefox-dev_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/abrowser-3.0-branding_3.0.10+nobinonly-0ubuntu0.9.04.1_amd64.deb
deleting pool/main/f/firefox-3.0/firefox-granparadiso-dev_3.0.10+nobinonly-0ubuntu0.9.04.1_all.deb
deleting pool/main/f/firefox-3.0/firefox-3.0-dev_3.0.10+nobinonly-0ubuntu0.9.04.1_i386.deb
If, at this point, you find that “debmirror” wants to remove whole subdirectories from your local mirror, then you should review the parameter values that you supplied, and correct them as required.
You can repeat the “debmirror” test run as often as you want, until you are satisfied with the results.
Running “debmirror” for Real.
When you’re ready to let “debmirror” actually bring your local mirror up-to-date, just run the command without the “--dry-run” option, leaving all other parameters unchanged:
Code:
debmirror --nosource --md5sums --passive \
--host=online-repository-host --root=ubuntu --method=http --progress \
--dist=dist-list --section=section-list --arch=arch-list \
~/UbuntuRepos
The following is an example of an actual “debmirror” command, with all values substituted into it:
Code:
debmirror --nosource --md5sums --passive \
--host=archive.ubuntu.com --root=ubuntu --method=http --progress \
--dist=jaunty,jaunty-backports,jaunty-security,jaunty-updates \
--section=main,multiverse,restricted,universe --arch=i386,amd64 \
~/UbuntuRepos
The output from the “debmirror” command will be mostly identical to that of the test run; this time, however, it will reallly perform the operations that it lists. As a result, your local mirror will have been properly set up and brought up-to-date once the command completes.
Updating your APT Sources.
With the necessary infrastructure in place, it is now time to add your local mirror to your “/etc/apt/sources.list” file, to make it known to the APT system. For each of the values that you listed in the “--dist” parameter on the “debmirror” command, add a line of the following form to the top of the file:
Code:
deb file:///home/username/UbuntuRepos/ distname section-list
As an example, if your username is “luvr,” and with the “--dist” and “--section” parameter values as above, these lines will look as follows:
Code:
deb file:///home/luvr/UbuntuRepos/ jaunty main,multiverse,restricted,universe
deb file:///home/luvr/UbuntuRepos/ jaunty-backports main,multiverse,restricted,universe
deb file:///home/luvr/UbuntuRepos/ jaunty-security main,multiverse,restricted,universe
deb file:///home/luvr/UbuntuRepos/ jaunty-updates main,multiverse,restricted,universe
Note:
Depending on your needs and preferences, you may want to leave out the “jaunty-backports” line. Backports are updates that were actually developed for later Ubuntu releases, and that were subsequently made available for the current version, albeit without any form of support.
Note:
Remember that you will need
root privileges in order to edit the
“/etc/apt/sources.list” file. For example, if you want to use the
“gedit” text editor, you will have to run the following command:
Code:
sudo gedit /etc/apt/sources.list
Alternatively, you can start the editor from the GNOME desktop by pressing
<Alt>-<F2> and running the following command line:
Code:
gksudo gedit /etc/apt/sources.list
Next, update your local package indexes:
Code:
sudo apt-get update
Keeping your Local Mirror Up-To-Date.
To keep your local mirror up-to-date, you will periodically have to rerun the “debmirror” command to resynchronise your mirror with the online repository, and subsequently update your local package indexes again—e.g.:
Code:
debmirror --nosource --md5sums --passive \
--host=archive.ubuntu.com --root=ubuntu --method=http --progress \
--dist=jaunty,jaunty-backports,jaunty-security,jaunty-updates \
--section=main,multiverse,restricted,universe --arch=i386,amd64 \
~/UbuntuRepos
sudo apt-get update
Bookmarks