Using Vagrant NFS Synced Folders for Faster File Sync
Learn how to enable Vagrant NFS synced folders for faster host‑guest file synchronization, with a sample Vagrantfile, performance notes, and pitfalls to avoid.
09 Feb 2026, 20:27 UTC

Enable NFS synced folders in Vagrant
To get near‑native file performance in a Vagrant box, enable NFS synced folders. This bypasses the slower VirtualBox shared‑folder implementation by using the host’s NFS daemon and the guest’s NFS client, keeping data in the kernel page cache.
Worked Vagrantfile example
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.network "private_network", type: "dhcp"
# Enable NFS synced folder for the project root
config.vm.synced_folder ".", "/vagrant",
type: "nfs",
mount_options: ["nolock,vers=3,udp", "dmode=775,fmode=664"]
end
How it works
When vagrant up runs, Vagrant:
- Starts the host’s NFS daemon (if not already running) and exports the host directory matching the first argument of
synced_folder. - Boots the guest VM and installs the
nfs-commonpackage (you must ensure it is present; on Ubuntu/Debian runsudo apt-get install -y nfs-commonas part of a provisioning script). - Mounts the exported directory inside the guest at the second argument (
/vagrant) using the supplied mount options.
Because the NFS traffic stays on the private network interface and uses UDP by default, latency is low and throughput approaches that of a native file system.
Limitations and common mistakes
- Host must run an NFS server. On macOS enable Remote Login or start
nfsdmanually; on Linux ensurenfs-kernel-serveris active. Windows hosts need thevagrant-winnfsdplugin or WSL2. - Firewall/port 2049. The guest must be able to reach the host’s IP on TCP/UDP port 2049. If you see
mount.nfs: Connection timed out, check the host’s firewall and that the NFS service is listening. - UID/GID mismatches. Files may appear owned by the wrong user. Fix by adding
uidandgidoptions or usingdmode/fmodeas shown. - Changing guest IP. NFS exports are tied to a specific host‑guest IP pair. If the guest gets a new DHCP address after a suspend/resume, the mount can go stale. Use a static private‑network IP or reload with
vagrant reloadafter IP changes. - Performance on Windows hosts. Without the plugin, Windows cannot act as an NFS server, so the fallback is the slower VirtualBox shared folder.
To verify that NFS is active, log into the guest with vagrant ssh and run:
mount | grep /vagrant
You should see a line containing type nfs and the options you specified. Then create a test file on the host and check its presence and timestamps inside the guest to confirm synchronization.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.