Joeri Verdeyen bio photo

Joeri Verdeyen

Web-engineer, cyclist, Nespresso lover, Strava pusher.

Twitter LinkedIn Instagram Github Stackoverflow Last.fm Strava

Speed up your Vagrant NFS mount

When mounting a project folder with a +1000 files (i.e. git repository), file access can become really slow. There are some easy fixes to speed things up.

mount_options

Add the following mount_options on your synced folder in your Vagrantfile

config.vm.synced_folder "./", "/var/www/", type: "nfs",  mount_options: ['rw', 'vers=3', 'tcp', 'fsc' ,'actimeo=2']
  • vers=3 specifies version 3 of the NFS protocol to use
  • tcp specifies for the NFS mount to use the TCP protocol.
  • fsc will make NFS use FS-Cache
  • actimeo=2 absolute time for which file and directory entries are kept in the file-attribute cache after an update

cachefilesd

Install cachefilesd, a Linux service that caches NFS file access.1

sudo apt-get install cachefilesd
sudo echo "RUN=yes" > /etc/default/cachefilesd

extra: Sublime Text 3

A default setting in Sublime Text 3 can also create an issue. Turning off atomic_save did the trick for me. Sublime Text > Preferences > Settings > User

{
    "atomic_save": false
}
  1. I only tested this on Ubuntu 14.04 

Thanks for reading

Feel free to leave a comment if you have remarks or like this post