Choosing NFS Synced Folders in Vagrant for Faster Local Development
When a developer runs a framework that touches thousands of tiny files — think npm install, Composer dump‑autoload, or asset compilation — the default VirtualBox shared folder becomes a bottleneck.
21 Jan 2026, 00:42 UTC

Why file I/O matters in a Vagrant box
When a developer runs a framework that touches thousands of tiny files — think npm install, Composer dump‑autoload, or asset compilation — the default VirtualBox shared folder becomes a bottleneck.
Switching to NFS synced folders
Vagrant can replace the VirtualBox implementation with an NFS mount when the host provides an NFS server and the guest has the NFS client installed. The change is a single line in the Vagrantfile:
config.vm.synced_folder ".", "/vagrant", type: "nfs"
On macOS and most Linux distributions the NFS server is built‑in; on Windows you need a third‑party server such as win‑nfs. Inside the guest you must install the client package (e.g., sudo apt-get install nfs-common on Ubuntu). The first vagrant up will prompt for the host password to allow the privileged mount.
Worked example: measuring file‑creation speed
- Start with the default shared folder. In the Vagrantfile use
type: "virtualbox"(or omit the type). - Boot the box:
vagrant up. SSH in:vagrant ssh. - Create a test directory and time the creation of 5 000 empty files:
mkdir -p /vagrant/perf_test time for i in {1..5000}; do touch /vagrant/perf_test/$i; doneRecord the real time reported by
time. Then halt the box, change the synced folder line totype: "nfs", and repeat the same steps. You should see a noticeably lower wall‑clock time and reduced host CPU usage (observable withtopor Activity Monitor).To confirm that the mount is indeed NFS, run inside the guest:
mount | grep /vagrantYou should see a line containing
type nfs(ornfs4depending on the host).Trade‑offs and practical limits
- Privileged access: mounting NFS requires root on the host, so Vagrant will ask for your password (or sudo) each time the VM is brought up.
- UID/GID mapping: files appear owned by the host user’s UID/GID inside the guest. If your application expects a specific ownership (e.g., www‑data), you may see permission errors unless you adjust the mount options or run the process as the matching UID.
- Windows hosts: the built‑in NFS server is absent; you must install an external NFS server or fall back to the slower VirtualBox shared folders or SMB synced folders.
- Network‑only: NFS works only over the host‑only network that Vagrant sets up; it does not function when the VM is using a purely NAT‑only configuration without a host‑only adapter.
Deciding and verifying
If your workload involves frequent reads/writes of many small files and you are on a macOS or Linux host, try the NFS line, reload the VM (vagrant reload), and run the file‑creation test above. Compare the times; a reduction of 30 %–70 % is typical for such workloads. On Windows, evaluate whether installing win‑nfs is worth the complexity; otherwise stay with the default shared folder or consider SMB if you need better performance without NFS.
Whenever you change the synced folder type, remember to run vagrant reload (which triggers a new mount) and verify the mount type with the mount command inside the guest.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.