Pre-fetch packages for Debian dist-upgrade

Recently, I had to upgrade a Debian 4 (Etch) to Debian 5 (Lenny) at a client facility connected to Internet with a « slow » 2Mbps SDSL link.

The problem is that downloading the packages while doing the upgrade on-site, during working hours, would take a significant time, and I had to minimize the downtime.

One solution would be to burn the 30 CDs, or 5 DVDs, from Debian, and upgrade the server from this pile of waffle.

Finally, after googling for apt and offline upgrades, I found a solution that would fit quite perfectly my needs.

The solution is to compute the set of packages required for the upgrade and pre-download them. Then, when on the client facility, I would just run `aptitude dist-upgrade’ and it would update from a local repository of theses pre-downloaded packages.

Here are the commands I used :

– Configure `/etc/apt/sources.list’ to point to the Lenny repositories, then update the apt database :

# aptitude clean
# aptitude update

– Compute the set of package required for the upgrade :

# mkdir upgrade-mirror && cd upgrade-mirror
# apt-get -qq --print-uris > pkg.list

– Download the packages to the `upgrade-mirror’ subdir :

# cat ../pkg.list | (cd upgrade-mirror && while read URI; do wget "$URI"; done)
# dpkg-scanpackages upgrade-mirror /dev/null | gzip > upgrade-mirror/Packages.gz

As I also needed PHP 5.3 from Zend Server, I also mirrored the Zend Server repo.

I left the download running during the night.

The download for the Lenny packages took about an hour (228MB of packages), plus another unknown time for the 415MB of the Zend Server mirror.

Then, in the morning, I arrived at the client facility, and started my upgrade using theses local/mirror repositories.

– Set `/etc/apt/sources.list’ to point to the `upgrade-mirror’ local repo, and to the classic `dist-upgrade’.

– Set `/etc/apt/sources.list’ to the official Lenny repo, and do a final `dist-upgrade’ to see if there is anything left to upgrade.

In one hour I had the base system upgraded with full support for PHP 5.3, and I had plenty of time left for upgrading the client application.

Ce contenu a été publié dans code. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*