简体   繁体   English

流浪者共享文件夹不同步

[英]Vagrant shared folder without sync

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). (我想使用我自己的rsync脚本,这正是我所需要的,而没有Vagrant文​​件共享性能损失的情况)。

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. 我在带有Virtualbox 5.0.12的Windows 7(主机)上使用Vagrant 1.8.1,来宾操作系统为Ubuntu 12.04。

You can indeed share a folder simply using the VirtualBox Manager. 实际上,您只需使用VirtualBox Manager即可共享文件夹。

  1. Disable the Vagrant synced folder (in the vagrantfile ): config.vm.synced_folder ".", "/vagrant", disabled: true 禁用Vagrant同步文件夹(位于vagrantfile ): config.vm.synced_folder ".", "/vagrant", disabled: true
  2. Install Guest Additions to VirtualBox 将来宾添加项安装到VirtualBox
  3. Open VirtualBox Manager and select Settings > Shared Folders > Adds new shared folder (sic) 打开VirtualBox Manager,然后选择设置>共享文件夹>添加新的共享文件夹(原文如此)
  4. Add your host path in "Folder Path:" and your guest name (eg FolderName ) in "Folder Name:" 在“文件夹路径:”中添加主机路径,在“文件夹名称:”中添加来宾名称(例如FolderName
  5. Your guest name will appear in the guest linux in /media/sf_FolderName 您的来宾名称将显示在/media/sf_FolderName的来宾Linux中
  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 . 我做了sudo adduser vagrant vboxsfsudo chmod 777 /media/sf_FolderName ,但对我而言它sudo chmod 777 /media/sf_FolderName -流浪用户仍然获得permission denied Those commands seem to have worked for others , but I have ended up just working as root, which does have access. 这些命令似乎对其他人有用 ,但是我最终只是以root身份工作,它具有访问权限。

Incidentally, here's my rsync formula (with a watch that polls every second) which works really well for me. 顺便说一句,这是我的rsync公式(带有每秒轮询的手表),对我来说真的很好。

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). 注意:仅当您在主机上进行更改时(例如,在Windows中使用编辑器进行开发),该方法才有效。 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. 如果您要在来宾上进行更改(例如git pull),您将要停止watch / rsync的运行,并手动朝另一个方向复制。 Not ideal, but at least developing with this setup is fast. 这并不理想,但是至少使用这种设置进行开发是很快的。

Thanks to Frederic Henri for nudging me in this direction. 感谢Frederic Henri在这个方向上推动我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM