Simple answer: SPEED
Most projects I work on a the moment are web related and I like my development environment to be as close to production as possible.
Therefore I set up a Debian Jessie some time ago and mounted my whole /Users/cb0/Sites directory into the VM. So I configured the shared folders inside the VirtualBox and used this code inside /etc/fstab inside the Debian.
Sites /Users/cb0/Sites vboxsf defaults,rw,uid=33,gid=33 0 0
This worked fine for custom php apps and even for symfony 1.4. Now I’m working on a symfony 2 project which seems to generate a whole bunch of cache files before starting to deliver the webpage.
This resulted in an average load time of 45s (yes seconds) which I could not bear for more than 2 pageloads. So I search for the bottleneck and found out that the creation of the cache files took too long. After reading some documentations I decided to try to mount the share over nfs instead of the vboxsf.
Here’s how to do it:
1. [Host] Create or open the file “/etc/nfs.conf” and insert the following line:
nfs.server.mount.require_resv_port = 0
2. [Host] Edit the /etc/exports file and configure your desired share folder like this:
/Users/cb0/Sites -mapall=501:20 -network 192.168.56.0 -mask 255.255.255.0
Replace “192.168.56″ with the address you have chosen for your Host-only Adapter.
3. [Host] Run the following 3 commands:
> sudo nfsd update > sudo nfsd checkexports > showmount -e
The ‘showmount’ command will output something like this if everything went fine:
# Exports list on localhost: /Users/cb0/Sites 192.168.56.0
4. [GUEST] Install necessary software. (As mentioned I use debian jessie)
sudo apt-get install nfs-common
5. [GUEST] Add the mount infos into the file /etc/fstab
192.168.56.1:/Users/cb0/Sites /Users/cb0/Sites nfs soft,intr,rsize=8192,wsize=8192 0 0
This tells debian to mount the directory /Users/cb0/Sites located on my host machine into the exactly same directory on my linux. (Note: You have to create the folder inside the guest first.) I do this for convenience, you could mount it somewhere else.
6. [GUEST] Now mount this share.
sudo mount /Users/cb0/Sites
and you are done.
After these simple steps and no other tuning my sf2 web project load in about 580ms. This is more than 70times faster than before.
I also noticed a small speedup in my other web apps. Now I can relax, sit back and continue my work on this project.