Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Still learning a bit about Vagrant, but here it goes. I have a pretty standard guest vm that has some software installed. I would like to access a few directories within the guest in a read/write fashion. So I added the config for a shared folder as follows:

config.vm.share_folder "test", "/home/vagrant/test", "./test"

Keep in mind I have content in my test folder. I need to be able to view and update that from the host. However, when I 'vagrant reload' with the empty host directory called test, all of the content on my guest is removed.

Is it possible to create a shared folder in which I can access content on the guest without destroying existing content?

share|improve this question
Shared folders share a folder on the host machine with the guest machine, not the other way around. – heavyd Mar 2 '13 at 0:04
Thats what I was afraid of, thanks for the response. – ConsultStan Mar 4 '13 at 17:13
If you want to share from guest to host, you can still do it one of the standard ways e.g. with a Samba share, or fuse-ssh. One of the advantages of vagrant mapping a host folder to the VM is you can easily share files between VMs via the host. This way round also makes it easier to edit files on the host but test on the guest, a common development pattern. – Ben XO Nov 24 '14 at 17:24

In case someone else comes by this problem, shared folders are indeed synced in both directions (from host to guest and from guest to host) but it depends on the type option.

In Linux this works out of the box without specifying the type option:

  1. Login into the virtual machine.
  2. Add a test file in /home/vagrant/test.
  3. Check your host folder and you will find the new file.

The problem comes in when you try to sync a folder after provisioning the virtual machine. In such case the guest folder will be sync'd to the host folder, which is empty.

Read the different types of shared folders.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .