Ubuntu: faster release upgrade

It might be high time to update to the latest Ubuntu 14.04.

I think that the upgrade process that is provided by Canonical is slightly underoptimal: if you're using a
local mirror which can provide a very fast download of all packages, they'll usually be disabled during the upgrade process, and an official mirror (possibile one very far away) will be employed.

This can lead to a very slow and painful upgrade process.

The solution is easy.

The following instructions regard moving from 12.04 (precise) to 14.04 (trusty)

Switch your sources

Assuming that your official ubuntu sources are configured from /etc/apt/sources.list just do something like:

sudo sed -i.old -e 's/precise/trusty/g' /etc/apt/sources.list

I'm not considering other sources in /etc/apt/sources.list.d, since they'll be disabled whatsoever; but if you happen
to have ubuntu sources there as well, you should repeat the SEDding process for each file.

Update your index

sudo apt-get update

Download updated packages without installing

sudo apt-get dist-upgrade --download-only

Revert to old sources

sudo mv -f /etc/apt/sources.list.old /etc/apt/sources.list

Update index again

sudo apt-get update

Rejoice!

Now you can just follow the upgrade instructions and
almost nothing will be downloaded during the upgrade, because everything is already on your hard drive.