Celeb Glow
general | March 06, 2026

How do I sync Vagrant sync folder with VirtualBox and CentOS/Windows?

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 or vagrant 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
[vagrant@localhost ~]$ cd /vagrant
[vagrant@localhost vagrant]$ ls
Vagrantfile vagrant.log
[vagrant@localhost vagrant]$ touch tmp.txt
[vagrant@localhost vagrant]$ ls
tmp.txt Vagrantfile vagrant.log
[vagrant@localhost vagrant]$ exit
logout
Connection to 127.0.0.1 closed.
Chloe@xps /cygdrive/c/Users/Chloe/Documents/server
$ ls
vagrant.log Vagrantfile

I tried to manually mount and it gave an error

[vagrant@localhost 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

virtual box shared folder settings dialog

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

2 Answers

I fixed it by changing the name (1st column) of /vagrant in VirtualBox to vagrant and manually running this command inside the guest:

[vagrant@localhost ~]$ sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
[vagrant@localhost vagrant]$ touch /vagrant/tmp.txt
[vagrant@localhost vagrant]$ exit
Connection to 127.0.0.1 closed.
Chloe@xps /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
1

I suggest that you update to Virtualbox to version 5.1.18 which solves that problem!

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy