I created a Vagrantfile with the following content:
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 are:
/vagrant
shared folder? I read shared folders are deprecated in favour of synced folders, and I never defined any shared folder in my Vagrantfile.I'm using Vagrant version 1.2.7 on MacOX 10.8.4.
By default, Vagrant stores its boxes after downloading in the directory defined by VAGRANT_HOME environment variable. As a result, On Mac OS X and Linux: ~/. vagrant.
If you are seeing less than ideal performance with synced folders, NFS can offer a solution. Vagrant has built-in support to orchestrate the configuration of the NFS server on the host and guest for you. Windows users: NFS folders do not work on Windows hosts.
Command: vagrant destroy [name|id] This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.
Using SCP. Another way to copy files and folders from host to guest in Vagrant is to use to SCP. Firstly, make sure you have scp installed on your host. If you don't have it, you can install the openssh-clients package if you're using Linux or install Cygwin if you're using Windows.
Basically shared folders are renamed to synced folder from v1 to v2 (docs), under the bonnet it is still using vboxsf
between host and guest (there is known performance issues if there are large numbers of files/directories).
/vagrant
in guestVagrant is mounting the current working directory (where Vagrantfile
resides) as /vagrant
in the guest, this is the default behaviour.
See docs
NOTE: By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant.
You can disable this behaviour by adding cfg.vm.synced_folder ".", "/vagrant", disabled: true
in your Vagrantfile
.
Based on the output /tmp
on host was NOT mounted during up time.
Use VAGRANT_INFO=debug vagrant up
or VAGRANT_INFO=debug vagrant reload
to start the VM for more output regarding why the synced folder is not mounted. Could be a permission issue (mode bits of /tmp
on host should be drwxrwxrwt
).
I did a test quick test using the following and it worked (I used opscode bento raring vagrant base box)
config.vm.synced_folder "/tmp", "/tmp/src"
output
$ 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
Within the VM, you can see the mount info /tmp/src on /tmp/src type vboxsf (uid=900,gid=900,rw)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With