Answer the question
In order to leave comments, you need to log in
How to set up Vagrant shared folders correctly?
I have a host machine: macOS Sierra 10.12.3
I have a vagrant box: debian 8
I'm trying to set up NFS shared folders between them. Rsync is not suitable, because two-way synchronization is needed, vboxfs is also not suitable, since the project is large, there are a lot of files - this file system works, but is catastrophically slow.
NFS mounts and syncs perfectly, and the project itself runs very fast. But the essence of the problem is that the mounted folder is given owner:group - 501:dialout. I understand that nfs is trying to take my user and my group from the host machine (macOS) and set the same user and group for the mounted folder. But - from the guest of the machine I can neither create a file, nor edit, nor delete (even under root). What kind of crutches did not try, the whole Internet rustled, even put a happy tambourine next to the laptop. To no avail.
How can I mount a folder using NFS via vagrant so that I can edit the files in it directly in the virtual machine itself?
Vagrant 1.9.2
VirtualBox 5.1.18
Answer the question
In order to leave comments, you need to log in
In general, the solution turned out to be quite banal and simple.
Specify the nfs type in the Vagrantfile.
We also specify the id of the user and group on behalf of which manipulations will take place in the mounted folder.
config.vm.synced_folder "/host/projects/mount-from-folder", "/guest/mount-to-folder", type: "nfs"
# Все действия с файлами в примонтированной папке будут производиться от лица текущего пользователя хост-машины
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
# Можно так же указать цифрами id любого юзера/группы
# Узнать их можно посмотрев файлы /etc/passwd и /etc/group
config.nfs.map_uid = 501
config.nfs.map_gid = 20
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question