VirtualBox Shared Folders vs NFS for Cross-Platform Vagrant Teams
0 reputation · 08 May 2023, 22:55 UTC
0 reputation · 08 May 2023, 22:55 UTC
A development team uses Vagrant with VirtualBox across macOS, Linux, and Windows hosts. The project involves a codebase with many small files where I/O latency directly affects test suite runtime. VirtualBox shared folders work everywhere without extra setup but exhibit high latency on large directory trees. NFS delivers lower latency on Unix-like hosts but is unavailable on Windows without third-party server software, and Vagrant does not automatically fall back to the default type when NFS is missing.
The Vagrantfile must declare a single synced-folder configuration that behaves predictably on all three host platforms without per-developer conditional logic or manual provider overrides.
map_uid/map_gid settings to avoid permission mismatches in the guest?35275 reputation · 09 May 2023, 01:25 UTC
map_uid and map_gid to the host user's UID/GID, while Windows shared folders typically present files as UID 1000/GID 1000 (the guest vagrant user). Explicit mapping is required for consistency, assuming the guest primary user is UID 1000.Vagrant does not silently fall back from NFS to VirtualBox shared folders when an NFS server is missing. Windows does not include an NFS server by default, so an unconditional type: :nfs fails on Windows hosts. Host-OS detection in the Vagrantfile is the standard zero-plugin workaround.
map_uid and map_gid to the host user's UID/GID unless overridden.vagrant user, UID 1000/GID 1000.chmod behavior can still differ between NFS and VirtualBox shared folders.host_os values, so verify the detection pattern on each exact developer setup.Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2204"
is_windows = RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin|windows/
config.vm.synced_folder ".", "/vagrant",
type: is_windows ? :virtualbox : :nfs,
nfs_udp: false,
map_uid: 1000,
map_gid: 1000
end
map_uid and map_gid are ignored by VirtualBox shared folders, so they are safe to include unconditionally.nfs_udp: false improves reliability on modern networks and is ignored when VirtualBox shared folders are active.vagrant up on macOS, Linux, and Windows hosts. Windows should not report a missing NFS server.touch /vagrant/ownership-check && stat -c '%u %g' /vagrant/ownership-check. Expect 1000 1000 on all three platforms.find /vagrant -type f | xargs cat > /dev/null and compare runtime; NFS should be materially faster on macOS and Linux than VirtualBox shared folders.vagrant plugin list contains no NFS server plugin such as vagrant-winnfsd.If your guest box does not use UID 1000/GID 1000 for the primary user, provide that UID/GID pair; the map_uid and map_gid values must match the guest user to avoid permission mismatches.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.