Last Updated: February 25, 2016
· mlafeldt

Speed up package download in Vagrant boxes

Inside Vagrant boxes like http://files.vagrantup.com/lucid64.box, apt is configured to fetch Debian packages from US servers, e.g. us.archive.ubuntu.com.

For people outside the US, here's a one-liner you can add to your Vagrantfile that will speed up the package installation process (put it in front of other provisioners):

config.vm.provision :shell, :inline => "sed -i 's/us.archive/de.archive/g' /etc/apt/sources.list"

This patches apt's sources.list file so that all packages will subsequently be downloaded from German servers, i.e. de.archive.ubuntu.com. Feel free to adapt it to your location.

1 Response
Add your response


Also you should add:
config.vm.provision "shell", inline: "apt-get update -y"
to update sources cache.

over 1 year ago ·