Vagrant synced directories

08 Jul 2016,

I’ve often been wanting to mount a dir on the host system, when spinning up a vagrant server.

Here is how I did it. First I had to install the vagrant-vbguest plugin. With this one liner

vagrant plugin install vagrant-vbguest

Then I added this to my Vagrantfile

Vagrant.configure("2") do |config|
 config.vm.synced_folder "tmp/", "/opt/tmp", owner: "root", group: "root"
end

and did a vagrant reload and presto - vagrant mounted the tmp folder inside /opt/tmp