Speeding up Vagrant

September 28, 2014

Many teams are moving their development environment over to Vagrant lately. It can have profound effects on reducing developer onboard time,  environment specific errors and even help non technical teammates get up and running with a local environment.

The only real issue with Vagrant is that out of the box it is slow. While it will never be as fast as a native environment, there are things you can do to speed up performance considerably.

1. Move to NFS

The biggest gain you can get is switching file systems over from the default Virtualbox shared folders to NFS. The best part is that switching couldn’t really be easier.

by default, Vagrant mounts drives like this:

config.vm.synced_folder "../data", "/vagrant_data"

all you have to do is add type: “nfs” like so:

config.vm.synced_folder "../data", "/vagrant_data", type: "nfs"

and you’re done!

The only issue you might run into is that unlike with Virtualbox shared folders, NFS uses whatever file permissions are already on your files. Where before you could do something like:

:mount_options => ['dmode=775', 'fmode=775']

now you’ll have to configure permissions on your laptop / desktop before initializing Vagrant.

The other caveat, which really isn’t a problem but can seem strange is that if you look at the files owner on the VM you’ll most likely see something like:


or something like that. Don’t be alarmed! This is a default user ID that comes on all systems. You’re user ( vagrant or whatever you set it to ) can still read / write on all of your files, it just looks weird.

2. Use more cores and memory

The next thing you can do is allocate more resources to the VM. Personally, I always use 100% of available cores and at least 2GB of memory if I can spare it. You can just add these lines to your Vagrantfile:

config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 4

This won’t help as much as the NFS fix but it should speed things up nicely for you.