When using NFS shares between OSX and Linux VirtualBox instances for development workflows, particularly with Git operations, we're observing unacceptable latency:
# Example of problematic git operation timing
$ time git status
real 0m5.214s
user 0m0.143s
sys 0m0.321s
The baseline setup shows significant performance gaps:
# Local disk vs NFS comparison (100 samples each)
Local:
Median: 1.020s | IOPS: 65.5k | Latency: 6μs
NFS:
Median: 6.390s | IOPS: 1.4k | Latency: 703μs
First, verify and optimize the VirtualBox network adapter settings:
# Check current network mode in VirtualBox
$ VBoxManage showvminfo [VM_NAME] | grep "NIC"
NIC 1: MAC: 080027BECB7A, Attachment: NAT, Cable connected: on
# Recommended configuration for NFS
$ VBoxManage modifyvm [VM_NAME] --nic1 bridged --bridgeadapter1 en0
$ VBoxManage modifyvm [VM_NAME] --nicpromisc1 allow-all
On the Ubuntu 12.10 NFS server (VirtualBox guest):
# /etc/exports optimization
/home/vagrant/share 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash,async)
# Kernel parameters (add to /etc/sysctl.conf)
sunrpc.tcp_slot_table_entries=128
sunrpc.udp_slot_table_entries=128
fs.nfs.nfs_callback_tcpport=8765
Replace the basic mount with optimized parameters:
# Current basic mount
mount -t nfs -o resvport 192.168.1.100:/home/vagrant/share /Users/me/share
# Optimized mount command
sudo mount -t nfs -o \
resvport,hard,nolock,noatime,nodiratime,vers=3,tcp,rsize=65536,wsize=65536,\
timeo=600,retrans=2,actimeo=0 \
192.168.1.100:/home/vagrant/share /Users/me/share
For immediate relief with Git operations:
# Configure Git to minimize stat calls
git config --global core.ignoreStat true
git config --global core.trustctime false
git config --global core.preloadIndex true
# Alternative: Use a local Git cache
git clone --reference /local/cache/repo.git nfs://path/to/repo.git
When NFS proves insufficient:
# Consider using sshfs instead
sshfs -o auto_cache,reconnect,defer_permissions,\
negative_vncache,volname=share \
vagrant@192.168.1.100:/home/vagrant/share /Users/me/share
# Or rsync for periodic sync
rsync -az --delete --info=progress2 \
vagrant@192.168.1.100:/home/vagrant/share/ /Users/me/share/
When working with Git operations on NFS-mounted directories between OSX and VirtualBox Linux VMs, we often encounter painfully slow performance. Here's what I've observed in my Vagrant setup:
# Typical git status delays
Local SSD: 0.2-0.5s
NFS mount: 3-5s
# Repository clone times (small repo)
Local: 5-10s
NFS: 2-5 minutes
Benchmarking reveals significant latency differences:
# dd benchmark (100 samples)
Local drive median: 1.02s
NFS mount median: 6.39s
VM internal median: 0.515s
# ioping results
Local latency: 6μs (65.5k IOPS)
NFS latency: 703μs (1.4k IOPS)
The key issues are metadata operations and small file throughput - exactly what Git depends on.
On your Ubuntu NFS server (/etc/exports), try these optimizations:
/path/to/share *(rw,async,no_subtree_check,no_root_squash,no_wdelay)
Then reload the config:
sudo exportfs -ra
sudo service nfs-kernel-server restart
For your OSX mount command (/etc/fstab or manual mount):
nfs://vm-ip/path /mount/point -o rw,resvport,hard,intr,timeo=600,retrans=2,noatime,actimeo=0
Key parameters explanation:
resvport
: Required for OSX compatibilityhard
/intr
: Better recovery from network issuesnoatime
/actimeo=0
: Reduce metadata updates
For your Vagrantfile:
config.vm.network "private_network", ip: "192.168.50.4",
virtualbox__intnet: "dev-network",
nic_type: "virtio"
Consider these additional optimizations:
- Use bridged instead of NAT networking if possible
- Enable virtio-net paravirtualization
- Increase network adapter buffer sizes
For better Git performance on NFS:
# Configure these git settings globally
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
Alternative approaches:
- Keep the working directory on local storage
- Use
git worktree
for multiple checkouts - Consider git cache-daemon for metadata
If NFS performance remains unacceptable:
- Switch to SMB3 (often better on OSX)
- Try sshfs with compression
- Use 9p filesystem in newer VirtualBox
- Consider Docker volumes for container workflows
Each solution has tradeoffs in setup complexity and feature support.