Running Meteor in a Vagrant (virtual)box

If you’re trying to run Meteor in a Vagrant VirtualBox, and getting an error like this when starting the local server:

vagrant@precise32:/vagrant$ meteor 
[[[[[ /vagrant ]]]]]

Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod

MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.

As the error message suggests, the problem is caused by the way Vagrant is sharing the src folder with the VM. The easiest solution (suggested here) is to move the Mongo DB data folder to somewhere on the VM, with a symlink in the Meteor folder:

vagrant@precise32:/vagrant/.meteor/local$ ln -s ~/db/                  
vagrant@precise32:/vagrant/.meteor/local$ ls -la
total 12
drwxr-xr-x 1 vagrant vagrant 4096 Jun 17  2013 .
drwxr-xr-x 1 vagrant vagrant 4096 Jun 17 21:47 ..
lrwxrwxrwx 1 vagrant vagrant   17 Jun 17  2013 db -> /home/vagrant/db/

And you should be back in business!

vagrant@precise32:/vagrant$ meteor 
[[[[[ /vagrant ]]]]]

=> Meteor server running on: http://localhost:3000/

UPDATE: this won’t work on a Windows host, apparently; due to the lack of support for symlinks. Sorry!