Vagriennye shared and synchronized folders

I created a Vagrantfile with the following contents:

Vagrant::Config.run do |config| config.vm.define :foo do |cfg| cfg.vm.box = 'foo' cfg.vm.host_name = "foo.localdomain.local" cfg.vm.network :hostonly, "192.168.123.10" end Vagrant.configure("2") do |cfg| cfg.vm.customize [ "modifyvm", :id , "--name", "foo" , "--memory", "2048", "--cpus", "1"] cfg.vm.synced_folder "/tmp/", "/tmp/src/" end end 

After vagrant up or vagrant reload I get:

 [foo] Attempting graceful shutdown of VM... [foo] Setting the name of the VM... [foo] Clearing any previously set forwarded ports... [foo] Fixed port collision for 22 => 2222. Now on port 2200. [foo] Creating shared folders metadata... [foo] Clearing any previously set network interfaces... [foo] Preparing network interfaces based on configuration... [foo] Forwarding ports... [foo] -- 22 => 2200 (adapter 1) [foo] Booting VM... [foo] Waiting for VM to boot. This can take a few minutes. [foo] VM booted and ready for use! [foo] Setting hostname... [foo] Configuring and enabling network interfaces... [foo] Mounting shared folders... [foo] -- /vagrant 

My questions:

  • Why /vagrant Vagrant mount the /vagrant shared folder? I read that shared folders are deprecated in favor of synchronized folders, and I never defined any shared folder in my Vagrantfile.
  • Why is the synchronized folder not configured?

I am using Vagrant version 1.2.7 on MacOX 10.8.4.

+45
vagrant
Aug 30 '13 at 8:50
source share
1 answer

shared folders vs synced folders

Basically, shared folders are renamed to a synchronized folder from v1 to v2 (docs), under the hood, it still uses vboxsf between the host and the guest (known performance problems with a large number of files / directories).

Vagrantfile directory set as /vagrant in guest

Vagrant sets the current working directory (where the Vagrantfile is located) as /vagrant on the guest system, this is the default behavior.

See docs

NOTE. By default, Vagrant will share your project directory (directory with Vagrantfile) with / vagrant.

You can disable this behavior by adding cfg.vm.synced_folder ".", "/vagrant", disabled: true to your Vagrantfile .

Why the synchronized folder does not work

Based on the output /tmp on the host was NOT set at run time.

Use VAGRANT_INFO=debug vagrant up or VAGRANT_INFO=debug vagrant reload to start the virtual machine for more information on why the synchronized folder is not installed. This may be a resolution issue (the /tmp mode bits on the host must be drwxrwxrwt ).

I checked a quick check using the following and it worked (I used the optional bento raring vagrant base box)

config.vm.synced_folder "/tmp", "/tmp/src"

Exit

 $ vagrant reload [default] Attempting graceful shutdown of VM... [default] Setting the name of the VM... [default] Clearing any previously set forwarded ports... [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Available bridged network interfaces: 1) eth0 2) vmnet8 3) lxcbr0 4) vmnet1 What interface should the network bridge to? 1 [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Running 'pre-boot' VM customizations... [default] Booting VM... [default] Waiting for VM to boot. This can take a few minutes. [default] VM booted and ready for use! [default] Configuring and enabling network interfaces... [default] Mounting shared folders... [default] -- /vagrant [default] -- /tmp/src 

Inside the virtual machine, you can see mounting information for /tmp/src on /tmp/src type vboxsf (uid=900,gid=900,rw) .

+81
Aug 30 '13 at 9:38 on
source share



All Articles