How do I sync Vagrant sync folder with VirtualBox and CentOS/Windows?
I fixed it by changing the name (1st column) of /vagrant
in VirtualBox to vagrant
and manually running this command inside the guest:
[[email protected] ~]$ sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
[[email protected] vagrant]$ touch /vagrant/tmp.txt
[[email protected] vagrant]$ exit
Connection to 127.0.0.1 closed.
[email protected] /cygdrive/c/Users/Chloe/Documents/server
$ ls
tmp.txt vagrant.log Vagrantfile
Not even selecting 'Auto mount' checkbox will mount it automatically. By the way, 1000 is the uid and gid of vagrant
user. id -u vagrant; id -g vagrant
You can add this to your Vagrantfile
:
config.vm.provision "shell", run: "always", inline: <<-SHELL
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
SHELL
Related videos on Youtube

Chloe
Updated on September 18, 2022Comments
-
Chloe about 1 month
I can't get the /vagrant folder to synchronize. It will synchronize from Windows host to CentOS guest, but only if I manually run
vagrant rsync
orvagrant up
, and will delete any new files in the guest. It won't sync from guest to host.$ vagrant ssh Last login: Wed Mar 15 21:00:00 2017 from 10.0.2.2 [[email protected] ~]$ cd /vagrant [[email protected] vagrant]$ ls Vagrantfile vagrant.log [[email protected] vagrant]$ touch tmp.txt [[email protected] vagrant]$ ls tmp.txt Vagrantfile vagrant.log [[email protected] vagrant]$ exit logout Connection to 127.0.0.1 closed. [email protected] /cygdrive/c/Users/Chloe/Documents/server $ ls vagrant.log Vagrantfile
I tried to manually mount and it gave an error
[[email protected] vagrant]$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant /sbin/mount.vboxsf: mounting failed with the error: Protocol error
I tried to manually set a shared folder in VirtualBox interface and restarted
It doesn't give any errors on
vagrant up
and there is nothing in the debug log.Version 5.1.16 r113841 (Qt5.6.2)
CentOS Linux release 7.3.1611 (Core)
Windows 8.1 -
Chloe over 5 yearsOh wow they just released it today. Just got the notice popup. Doesn't Oracle have regression tests so they stop breaking things?
-
Chloe over 5 yearsThat still doesn't work. I upgraded to 'Version 5.1.18 r114002 (Qt5.6.2)', removed the manual mount provision lines in my answer, started the box, touched
/vagrant/tmp.txt
, and the file still did not appear in my host folder. -
Zimmi almost 5 yearsSuccessfully used your solution, thanks for sharing it ! (tried many other proposal, none worked for me). After installing 3 ubuntu and 2 debian boxes, I noticed that ubuntu boxes are ok : hashicorp/precise64, ubuntu/trusty64 and ubuntu/xenial64 didn't show the problem, but debian aren't ok : debian/(jessie64|stretch64) demonstrated the same problem and needed your fix. In case someone wants to try to reproduce, host OS is Windows 10, with VirtualBox 5.2.2, guest additions + vagrant-vbguest plugin installed. Did you find info about the cause of this problem ?