1

Vagrant uses the words "share" and "sync" seemingly interchangeably. Is there a difference? If so, what is the difference?

IMO, "sync" implies that the data is duplicated in two places, and Vagrant does some magic to ensure that changes to one are also made to the other. This is a slightly different semantics to "sharing". Which is Vagrant doing, or can it do both?

EDIT: for example, say, I want a VM running MySQL server, but storing the database files on the host. Is this kind of setup the kind of thing that shared/syncd directories are appropriate for? E.g., do I have a guarantee of atomicity/transactionality? Sharing semantics would guarantee this, but syncing semantics possibly wouldn't.

(To make things worse, there's also Vagrant Share, which is unrelated to syncing or sharing.)

jameshfisher
  • 34,029
  • 31
  • 121
  • 167

1 Answers1

1

shared folder (v1 terminology) VS synced folder (renamed in v2)

In short: Shared Folders is more VirtualBox specific (vboxsf) and have known performance issues as number of files grows.

Vagrant v2 (vagrant 1.1.x, 1.2.x +) docs use a more generic name called Synced Folder, which now includes many options: default vboxsf, rsync, samba/CIFS, NFS.

By default, vagrant sync the project directory (where Vagrantfile resides) with /vagrant within the guest. This can be disabled by explicitly disable it in Vagnrantfile and do a vagrant reload.

e.g. config.vm.synced_folder ".", "/vagrant", disabled: true

To see a long story, see this answer: https://stackoverflow.com/a/18529697/1801697

Let's talk about sync

For vboxsf and nfs, host and guest folders (I mean synced folders) are always in sync (changes made on either side is synced to the other).

NOTE: SMB/CIFS should be the same but I've never used it.

In vagrant 1.5, rsync type is added, which makes manual sync possible, by default it sync from host to guest upon 1st vagrant up. I personally prefer rsync if real-time sync between host and is NOT needed.

BTW: Vagrant share is something different, it's sharing SSH access or other services via a cloud gateway.

Community
  • 1
  • 1
Terry Wang
  • 13,840
  • 3
  • 50
  • 43