On this page
Ubuntu: Using apt-p2p For Faster Upgrades From Hardy To Intrepid
Author: ernesto (torrentfreak.com)
Last Change: october 29 2008
ernesto has today published on TorrentFreak a great howto on how to lessen the burden of the Canonical Servers for the upgrade to the new stable release of Ubuntu 8.10 - Intrepid Ibex. With his permission I publish this howto here also.
What is apt-p2p?
According to the Ubuntu package information Apt-P2P is a helper for downloading Debian packages files with APT. It will download any needed files from other Apt-P2P peers in a peer-to-peer manner, and so reduce the strain on the Debian mirrors.
However there is no apt-p2p packages yet in Hardy. However we can use the version directly from Intrepid.
Step 1: Setting sources.list to a close-local mirror
First off, it's definitely recommended to reset to a local mirror. This way, you will download any needed files from a closer and supposedly faster source.
Either do an auto-check: System -> Administration -> Software Sources -> Download From: -> Other -> Select Best Server
(It'll run a couple hundred tests (takes less than five minutes) and select the best mirror for you. Make sure to remember which mirror it is, because you will need that later.)
Or select your local mirror yourself according to your country.
Step 2: Disable 3rd Parties repositories
It is also very much recommended to disable 3rd party repositories! If you don't know exactely what you are doing, go to the 3rd Parties tab and deselect all of the entries there.
Step 3: Install apt-p2p
Next you need to install "apt-p2p". Version 0.2.5 is needed because of a major bug in older versions. This is beta software, so it might not be stable for everybody. If it can't download the file via BitTorrent, however, it will revert to http download.
As apt-p2p is not in the hardy repos yet, we have to fetch it from a server directly. Below I have have two scripts for 32-bit and 64-bit. Use the according one:
For 32-bit versions use this script:
#!/bin/bash mkdir /tmp/apt-p2p cd /tmp/apt-p2p wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/universe/a/apt-p2p/apt-p2p_0.1.5_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/p/python-debian/python-debian_0.1.11_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted/python-twisted-core_8.1.0-4_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted-web2/python-twisted-web2_8.1.0-1_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/p/python-pysqlite2/python-pysqlite2_2.4.1-1_i386.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted/python-twisted-bin_8.1.0-4_i386.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/z/zope3/python-zopeinterface_3.3.1-7build1_i386.deb dpkg -i python-zopeinterface_3.3.1-7build1_i386.deb dpkg -i python-twisted-bin_8.1.0-4_i386.deb dpkg -i python-twisted-core_8.1.0-4_all.deb dpkg -i python-twisted-web2_8.1.0-1_all.deb dpkg -i *.deb
For 64-bit versions use this script:
#!/bin/bash mkdir /tmp/apt-p2p cd /tmp/apt-p2p wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/universe/a/apt-p2p/apt-p2p_0.1.5_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/p/python-debian/python-debian_0.1.11_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted/python-twisted-core_8.1.0-4_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted-web2/python-twisted-web2_8.1.0-1_all.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/p/python-pysqlite2/python-pysqlite2_2.4.1-1_amd64.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/t/twisted/python-twisted-bin_8.1.0-4_amd64.deb wget http://mirror.switch.ch/ftp/mirror/ubuntu/pool/main/z/zope3/python-zopeinterface_3.3.1-7build1_amd64.deb dpkg -i python-zopeinterface_3.3.1-7build1_amd64.deb dpkg -i python-twisted-bin_8.1.0-4_amd64.deb dpkg -i python-twisted-core_8.1.0-4_all.deb dpkg -i python-twisted-web2_8.1.0-1_all.deb dpkg -i *.deb
Save the according script into a file called "apt-p2p.sh" on your desktop. Then open a terminal (Applications > System > Terminal) and issue those commands (you'll be prompted for your user password):
sudo sh apt-p2p.sh
Those little scripts will create a apt-p2p folder in the /tmp folder.
Then it will enter that folder.
Then it will download apt-p2p from the intrepid repositories (they work fine on hardy) including all dependencies.
At the end it will inntall them in the required order.
Step 4: Prepare the sources.list
Once installed type the following:
sudo cp /etc/apt/sources.list /etc/apt/sources.list-apt-p2p-backup
gksudo gedit /etc/apt/sources.list
Now you are looking at the sources.list file for Ubuntu; this specifies which servers to contact for updates and new programs. You should see a bunch of lines that look similar to this:
deb http://archive.canonical.com/ubuntu hardy partner deb-src http://archive.canonical.com/ubuntu hardy partner deb http://*mirror-address*/ubuntu/ hardy main universe restricted multiverse deb-src http://*mirror-address*/ubuntu/ hardy main universe restricted multiverse
where **mirror-address** is the address of the mirror you chose earlier.
Don't worry, you may not have all of these, and you may have more. However, you only want to change ones that are similar to these. You want to change these to look like this:
deb http://localhost:9977/archive.canonical.com/ubuntu hardy partner deb-src http://localhost:9977/archive.canonical.com/ubuntu hardy partner deb http://localhost:9977/*mirror-address*/ubuntu/ hardy main universe restricted multiverse deb-src http://localhost:9977/*mirror-address*/ubuntu/ hardy main universe restricted multiverse
So basically just insert "localhost:9977" after the "http://" Now close the program and save the file.
Note: If you messed anything up, go back to the terminal and run this command:
sudo cp /etc/apt/sources.list-apt-p2p-backup /etc/apt/sources.list
This WILL overwrite your sources.list file with your backup and we are almost done!
Step 5: Update the packages & upgrade to Intrepid
In order to update the packages now type in the terminal:
sudo apt-get update
This will update the list of software, as well as fully integrate apt-p2p. If you get any errors, run the following commands (*Warning:* If not done carefully, these commands could destroy your system):
sudo rm -rf /var/cache/apt-p2p/cache/*
sudo apt-get update
Once everything looks okay, you'll want to forward the ports for apt-p2p to your system (if you have a router, see http://portforward.com, port for apt-p2p is 9977 TCP and UDP). At this point, you're all set to receive regular updates via BitTorrent. If you want to upgrade to Intrepid ahead of time you may type one of the following commands in the terminal:
sudo update-manager -d
Click then on the "upgrade" button on the top right of that window and follow the wizard. When asked, that no valid mirror was found and whether it shall replace hardy with intrepid, then select "Yes".
sudo apt-get dist-upgrade
Note: When issuing a "dist-upgrade" in the terminal you will first need to manually alter the entries in the sources.list from "hardy" to "intrepid".
Now you're all set, and by using BitTorrent to update Ubuntu you will be updated much faster, and help relieve the strain on the update servers on launch day. As always, tips and suggestions are welcome in the comments.