Speed up Vagrant + VMWare on OSX

Matt Bryson
2 min readMay 3, 2022

How we sped up our dev environment web server by almost 10X!

Photo by Agê Barros on Unsplash

TL;DR

check out the solution here.

The issue

Recently we moved from VirtualBox to VMWare to host our dev environment. (In a nutshell We are running Ubuntu Server in VMWare, managed by Vagrant on an OSX Host).

At first all was good, but we soon realised that after about 15 minuets of up time, the server would slowly grind to a halt and become almost unusable.

Having a look for what was up we could see that vmhgfs-fuse was using over 100% of the CPU when trying to serve files from the host — not ideal!

We used shared folders to map the source files on the host to the guest OS, and by default, the VMWare adapter for Vagrant uses fuse to map the shares.

However, there appears to be a known issue that has yet to be resolved which causes it to slowly grind to a halt.

So, we changed over to nfs and the site now loads like lightning.... well… like it should do in the first place!

The Solution — NFS

First up you need to change the mount type in the Vagrant file by adding type:“nfs” to each of your share folders.

config.vm.synced_folder “.”, “/var/www/html”, type:“nfs”

You may also have to remove some invalid options such as owner and group as these are not applicable in nfs shares.

Also, at the time of writing Vagrant 2.2.19 failed to create the nfs share due to this bug, erroring with:

`resolve_host_path’: uninitialized constant VagrantPlugins::HostDarwin::Cap::Version (NameError)

The fix is to either downgrade vagrant, or run this one-liner to patch it:

sudo curl -o /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/darwin/cap/path.rb https://raw.githubusercontent.com/hashicorp/vagrant/42db2569e32a69e604634462b633bb14ca20709a/plugins/hosts/darwin/cap/path.rb

And now the page loads almost instantly!

Other Issues

We also had an issue where it had crashed trying to create the NFS shares, and was stuck with invalid configuration. On each boot it was saying a conflicting share was already present.

To fix this, you can simply delete the vagrant NFS share config from the host by editing the /etc/exports file on you OSX Host — removing all the vagrant entries. Then try again and it should be fine.

The one downside is that on vagrant up it will prompt for permissions to configure the NFS share — but thats a small price to pay for the time saved waiting for page loads!

--

--