How to sync Vagrant sync folders with VirtualBox and CentOS/Windows?


Chloe

I can't get the /vagrant folder to sync. It will sync from the Windows host to the CentOS guest, but only if I manually run vagrant rsyncor vagrant up, it will delete any new files in the guest. It doesn't sync between the guest and the 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 install manually but got 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 set up shared folders manually in the VirtualBox interface and rebooted

Virtual Box Shared Folder Settings dialog

It doesn't give any errors vagrant upand there is nothing in the debug log .

Version 5.1.16 r113841 (Qt5.6.2)
CentOS Linux Version 7.3.1611 (Core)
Windows 8.1

Chloe

I fixed it by changing the name (first column) /vagrantin VirtualBox to vagrantand 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 the "Automount" checkbox will mount it automatically. By the way, 1000 is the vagrantuser 's uid and gid .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


Vagrant, VirtualBox, Supervisord: When to install sync folders?

Trevor I'm running a virtual machine with Supervisord to start and maintain some important background processes. I use vagrant and virtualbox to create virtual machines and use puppet to configure them. When the machine starts, supervisor captures all .conf fi

How to use NFS for vagrant sync specific folders?

Kim Stacks Host: OS X Mavericks Guest computer: Ubuntu 14.04 VM software: VirtualBox 4.3.14 In my Vagrantfile I have the following and it works fine: config.vm.synced_folder "~/Documents/WebApps", "/var/virtual/WebApps", id: "vagrant-root", owner: "www-

How to use NFS for vagrant sync specific folders?

Kim Stacks Host: OS X Mavericks Guest computer: Ubuntu 14.04 VM software: VirtualBox 4.3.14 In my Vagrantfile I have the following and it works fine: config.vm.synced_folder "~/Documents/WebApps", "/var/virtual/WebApps", id: "vagrant-root", owner: "www-

vagrant - Vagrantfile: Sync multiple folders

username I tried the following to sync multiple folders from the host computer to the guest computer. But only one folder is synced and the next one is synced. config.vm.synced_folder "host/site1", "/var/www/site1" config.vm.synced_folder "host/site2", "/var

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

vagrant - Vagrantfile: Sync multiple folders

username I tried the following to sync multiple folders from the host computer to the guest computer. But only one folder is syncing and the next one is syncing. config.vm.synced_folder "host/site1", "/var/www/site1" config.vm.synced_folder "host/site2", "/v

vagrant - Vagrantfile: Sync multiple folders

username I tried the following to sync multiple folders from the host computer to the guest computer. But only one folder is synced and the next one is synced. config.vm.synced_folder "host/site1", "/var/www/site1" config.vm.synced_folder "host/site2", "/var

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

vagrant - Vagrantfile: Sync multiple folders

username I tried the following to sync multiple folders from the host computer to the guest computer. But only one folder is synced and the next one is synced. config.vm.synced_folder "host/site1", "/var/www/site1" config.vm.synced_folder "host/site2", "/var

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

Vagrant sync folders without reloading?

Timothy Priam I have a file on my host that ~/ansible/provisioning/playbook.ymlcorresponds /vagrant/provisioning/playbook.ymlto the guest file. Every time I change a file on the host, the changes don't show up on the guest unless I run vagrant reloadthat to fu

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

Vagrant: How to sync folders from guest back to host?

kakat Why, because it is difficult to work and edit the code through the legacy editor in the guest. The whole point of vagrant is to make it easier for developers, right :)? So please can someone guide me in this case: Need to work on a project. This is the g

How to properly sync /folders?

and I have a btrfs snapshot and /I want to use it in the rsynccurrent /folder. As a form of "rollback" if needed. My question is, for example, which folder should I avoid -xto prevent rsync downgrading to other subvolumes, but which folder should I also exclud

How to properly sync /folders?

and I have a btrfs snapshot and /I want to use it in the rsynccurrent /folder. As a form of "rollback" if needed. My question is, for example, which folder should I avoid -xto prevent rsync downgrading to other subvolumes, but which folder should I also exclud

Vagrant sync folders not working on Windows 10

Rafael Reyes I'm trying to sync a folder from Windows 10 Hosto to an ubuntu guest and I get this error: $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'ubuntu/trusty64' is up to date... ==> default: Cleari

Time out of sync with VirtualBox + Vagrant + Homestead

Frederick Whenever my computer goes to sleep, the time in the Homestead environment is out of sync. The time on wakeup is not updated, it just persists from the time the computer starts going to sleep. This forced me to eliminate and then ascend the tramp. Ver

Time out of sync with VirtualBox + Vagrant + Homestead

Frederick Whenever my computer goes to sleep, the time in the Homestead environment is out of sync. The time on wakeup is not updated, it just persists from the time the computer starts going to sleep. This forced me to eliminate and then ascend the tramp. Ver