3
votes

How can I have a shared folder (access to the same folder from both host and guest machines) WITHOUT any syncing method running? (I want to use my own rsync script which is exactly what I need without the Vagrant file sharing performance penalties).

I have tried

config.vm.synced_folder ".", "/vagrant", disabled: true

but it disables the entire share.

I'm using Vagrant 1.8.1 on Windows 7 (host) with Virtualbox 5.0.12 and guest OS is Ubuntu 12.04.

1
for the VirtualBox provider, sync_folder is VB's shared folder and by default it is synced - you can look at specific mounting option in VB but I doubt this can be achieved - if you disable you can mount the drive using your own script ?Frederic Henri

1 Answers

1
votes

You can indeed share a folder simply using the VirtualBox Manager.

  1. Disable the Vagrant synced folder (in the vagrantfile): config.vm.synced_folder ".", "/vagrant", disabled: true
  2. Install Guest Additions to VirtualBox
  3. Open VirtualBox Manager and select Settings > Shared Folders > Adds new shared folder (sic)
  4. Add your host path in "Folder Path:" and your guest name (eg FolderName) in "Folder Name:"
  5. Your guest name will appear in the guest linux in /media/sf_FolderName
  6. Give your preferred guest user access to the folder. I did sudo adduser vagrant vboxsf and sudo chmod 777 /media/sf_FolderName and it DID NOT WORK for me - vagrant user still gets permission denied. Those commands seem to have worked for others, but I have ended up just working as root, which does have access.

Incidentally, here's my rsync formula (with a watch that polls every second) which works really well for me.

sudo watch -n 1 rsync -avh --delete --exclude-from=/media/sf_FolderName/FOLDERTOCOPY/rsync-exclude.txt /media/sf_FolderName/FOLDERTOCOPY /path/to/destination

NOTE: It works only if you're making changes on the host (eg developing using editor in Windows in my case). If you're making changes on the guest (eg git pull) you're gonna wanna stop this the watch/rsync from running and manually copy back in the other direction. Not ideal, but at least developing with this setup is fast.

Thanks to Frederic Henri for nudging me in this direction.