Vagrant: synced folders not automatically sharing in centos 7

Created on 18 Sep 2016  ·  3Comments  ·  Source: hashicorp/vagrant

Please, inform if this is not the correct place to post this. Thanks

After vigorously googling the web, I still can't get the synced folders to work on CentOS7. I have gotten it
to work on Ubuntu out-of-the-box. All my production servers are CentOS. Ubuntu was for testing. I want
to edit the source on my host box and run it on the guest, Sinatra, for example.

Snippets from both with 'vagrant up'
centos/7
==> default: Rsyncing folder: /home/lewisb/src/ruby-dev/web-dev/ => /vagrant
ubuntu/wily64
==> default: Mounting shared folders... default: /vagrant => /home/lewisb/src/ruby-dev/sinatra-dev-box

Vagrant version

Vagrant 1.8.5

Host operating system

Fedora Linux 4.7.3-200.fc24.x86_64
VirtualBox 5.0.26r108824
Ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

Guest operating system

Centos 7
Linux web-dev 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.hostname = 'web-dev'
  config.vm.provider 'virtualbox' do |v|
    v.memory = 4096
    v.cpus = 2
    v.gui = true
  end
  config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true
end

Expected behavior

I should be able to create and modify files on either host or guest and have the results automatically
synced. Ubuntu/Wiley does this out of the box.

Actual behavior

I have to vagrant reload to get the files synced. Snipped output from 'vagrant reload'

==> default: Machine booted and ready!
[default] GuestAdditions 5.0.26 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Rsyncing folder: /home/lewisb/src/ruby-dev/web-dev/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`

Steps to reproduce

  1. Destroy/create the vm using centos/7
  2. Ssh to guest after setting the permissions to 0600 on .ssh/authorized_keys file on guest
  3. Change directory to /vagrant and touch foo
  4. Check for existance of file foo on host - doesn't exist
  5. Reload vagrant and the file appears
synced-foldergeneral

Most helpful comment

I know this is a closed issue, but I would like to share how I solved this issue.

I had this issue with the centos/7 box as well. The box provider sets rsync as the default sync mechanism. You can see it in the box Vagrantfile. On my machine it was located here: ~/.vagrant.d/boxes/centos-VAGRANTSLASH-7/1804.02/virtualbox/Vagrantfile

To use Virtual Box, just add it to your VM Vagrantfile. It will look like:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  # Shared folder setting
  config.vm.synced_folder ".", "/vagrant", type: 'virtualbox'
  # Other settings...
end

Also, before running vagrant up, you have to install Virtual Box guest additions plugin for vagrant:

vagrant plugin install vagrant-vbguest

Once you do these 2 steps, run vagrant up and the shared folders should work properly, bidirectionally.

Source: https://stackoverflow.com/questions/46230783/vagrant-synced-folder-without-reload

All 3 comments

Hi! The issue has to do with guest additions not being installed on the box. I pulled the centos/7 box to confirm and it indeed does not include guest additions. If you see the guest additions being available after a reload, I'm guessing that you have the vbguest plugin installed. To make vagrant up work as expected "out of the box", you'll need to install guest additions on the guest and repackage the box, or use a different box (like the bento centos box).

Cheers!

I know this is a closed issue, but I would like to share how I solved this issue.

I had this issue with the centos/7 box as well. The box provider sets rsync as the default sync mechanism. You can see it in the box Vagrantfile. On my machine it was located here: ~/.vagrant.d/boxes/centos-VAGRANTSLASH-7/1804.02/virtualbox/Vagrantfile

To use Virtual Box, just add it to your VM Vagrantfile. It will look like:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  # Shared folder setting
  config.vm.synced_folder ".", "/vagrant", type: 'virtualbox'
  # Other settings...
end

Also, before running vagrant up, you have to install Virtual Box guest additions plugin for vagrant:

vagrant plugin install vagrant-vbguest

Once you do these 2 steps, run vagrant up and the shared folders should work properly, bidirectionally.

Source: https://stackoverflow.com/questions/46230783/vagrant-synced-folder-without-reload

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DreadPirateShawn picture DreadPirateShawn  ·  3Comments

OtezVikentiy picture OtezVikentiy  ·  3Comments

dorinlazar picture dorinlazar  ·  3Comments

RobertSwirsky picture RobertSwirsky  ·  3Comments

rhencke picture rhencke  ·  3Comments