Choosing a Vagrant Synced-Folder Mechanism: NFS vs rsync vs SMB vs VirtualBox Defaults
Vagrant's default synced folder is slow for file-heavy work. Compare NFS, rsync, SMB, and VirtualBox shared folders by host OS, sync direction, and performance — then configure and verify NFS.
30 Jul 2025, 10:21 UTC

Your Vagrant VM boots fine, but every build inside it crawls. git status takes ten seconds, npm install takes minutes, and file watchers never fire. The culprit is almost always the synced folder — the mechanism Vagrant uses to share your project directory between host and guest. The default (VirtualBox shared folders) is convenient but slow for file-heavy workloads, and switching to NFS, rsync, or SMB is usually a one-line change with a large payoff. This guide helps you pick the right one and verify the switch actually happened.
The decision and its constraints
Three constraints narrow the choice quickly:
- Host OS. NFS requires a Unix-like host (Linux or macOS); it is not supported on Windows hosts. SMB is the practical bidirectional option on Windows.
- Sync direction. rsync is one-way, host to guest. If anything inside the guest must write back to your project tree (generated code, migrations, logs you inspect on the host), rsync is the wrong tool.
- Filesystem performance. If your workload is light on file I/O, the zero-config default may be fine and the decision ends here.
This guidance assumes the VirtualBox provider. Hyper-V and Docker handle folder sharing differently, so confirm your provider before applying it.
Comparing the supported options
| Mechanism | Direction | Host support | Performance | Setup cost |
|---|---|---|---|---|
| VirtualBox shared folders | Bidirectional | All | Poor with many small files | None (default) |
| NFS | Bidirectional | Linux, macOS | Near-native | Static IP, sudo for /etc/exports |
| rsync | Host → guest only | All | Fast (files are local to guest) | Low; needs rsync-auto for continuous sync |
| SMB | Bidirectional | Windows (primarily) | Better than vboxsf, slower than NFS | Credentials, elevated prompt |
Trade-offs in practice
VirtualBox shared folders are bidirectional and need no configuration, which is why they are the default. They fall over on workloads with many small file operations — node_modules, large checkouts, builds — because every file operation crosses the host/guest boundary.
NFS gives near-native I/O and bidirectional sync, making it the standard choice on Linux and macOS hosts. The costs: you must define a private network with a static IP, and Vagrant edits /etc/exports, which requires root. On macOS, expect a sudo prompt on each vagrant up unless you configure passwordless NFS exports — a common friction point.
rsync copies files into the guest, so the guest sees a local filesystem and reads are fast. The catch is serious: edits made inside the guest silently disappear on the next sync or reload. Continuous sync also requires running vagrant rsync-auto in a separate terminal. It suits read-heavy guest workloads like running a server against code you only edit on the host.
SMB is the bidirectional answer for Windows hosts. It requires credentials and an administrator-elevated prompt during vagrant up, and it performs better than VirtualBox shared folders but generally worse than NFS.
One caveat that applies to every mechanism: inotify-based file watchers inside the guest often do not receive events for host-side changes over VirtualBox shared folders or NFS. If your dev server does not reload on edits, switch the watcher to polling mode before blaming the sync layer.
Concrete implementation: NFS
Edit your Vagrantfile on the host (no special permissions needed to edit; vagrant up will prompt for sudo to update NFS exports):
Vagrant.configure(\"2\") do |config|\n config.vm.box = \"ubuntu/jammy64\"\n\n config.vm.network \"private_network\", ip: \"192.168.56.10\"\n\n config.vm.synced_folder \".\", \"/vagrant\", type: \"nfs\", nfs_udp: false\nendThe private network with a static IP is required — NFS mounts over that interface. nfs_udp: false forces TCP, which avoids UDP-related mount problems on some host OS versions. Replace the IP with any unused address on your host-only network, and replace /vagrant with your preferred guest path.
Regardless of mechanism, a high-leverage pattern is excluding dependency directories from the sync:
config.vm.synced_folder \".\", \"/vagrant\", type: \"nfs\",\n nfs_udp: false,\n exclude: [\"node_modules/\", \"vendor/\", \".git/\"]Keeping node_modules or vendor on the guest filesystem (installing them inside the VM) mitigates most performance and file-watching problems no matter which mechanism you choose.
Validate the switch
Do not assume the type in your Vagrantfile was used — Vagrant can fall back silently in some configurations. Check three things:
- Confirm the mechanism. Run
vagrant upon the host and read the output for the mounted folder type (it should say NFS, and on macOS you should see the sudo prompt for exports). Inside the guest,vagrant sshthenmount | grep vagrantshould show an nfs mount. - Confirm sync direction. Create a file on the host and verify it appears in the guest; create one in the guest and verify it appears on the host. For rsync, the second file must not appear — if it does, you are not using rsync.
- Measure the improvement. Time a representative file-heavy command inside the guest before and after the switch, e.g.
time git statusor a package install. A move from vboxsf to NFS typically shows a dramatic difference on file-heavy operations; if timings are identical, suspect the mount did not actually change.
Limitations
Synced-folder behavior is provider- and Vagrant-version-sensitive; check vagrant --version and your provider's documentation if behavior diverges from the above. NFS adds a host-side dependency (an NFS server) that corporate laptops sometimes lack or restrict. And none of these mechanisms fix file-watching over the mount — plan on polling for host-side change detection.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.