Vagrant on Windows – Improve slow performance by using SMB instead of NFS

I love Vagrant, its a great tool for development. Sadly, once your project gets too big, performance really drops off a cliff on Windows. Running a Symfony2 project, I was getting ~20 second page refresh times. Apparently this relates to VirtualBox NFS on the shared folder.

 

A few people mentioned using Samba instead of NFS, but I couldn’t find anyone who had successfully used it. I gave it a go, and can confirm, it works a treat.

 

So first off, ssh into your Vagrant box:

vagrant ssh

 

then install Samba and edit the conf file

apt-get install samba
sudo nano /etc/samba/smb.conf

and add in:

[shared]
comment = Local Dev Server – /var/www
path = /var/www
browsable = yes
guest ok = yes
read only = no
create mask = 0777
force user = root
force group = root
#[shared] End

after that restart the Samba server

sudo restart smbd
sudo restart nmbd

Then I copied all the files in my project to my new Samba share directory ( called in this case ‘shared’).
after that I edited my Vagrantfile to make sure the NFS share was definitely turned off.

config.vm.synced_folder “.”, “/vagrant”, disabled: true

Share your love
Kieron Howard
Kieron Howard
Articles: 53

2 Comments

  1. Hi, I want to install Samba with Vagrant for my project Symfony2.
    But when I boot my box, the process block on first line … :/

    C:\vagrant\puphpet\vm1>vagrant reload –provision
    ==> default: Attempting graceful shutdown of VM…
    ==> default: Checking if box ‘puphpet/centos65-x64’ is up to date…
    ==> default: A newer version of the box ‘puphpet/centos65-x64’ is available! You
    currently
    ==> default: have version ‘1.2’. The latest is version ‘2.0’. Run
    ==> default: `vagrant box update` to update.
    ==> default: Clearing any previously set forwarded ports…

    Sometime the last line about fowarded port is not there and sometime yes…
    I really don’t know what this mean :/

    • The message states that the box is not the latest version. It suggests running:

      vagrant box update

      to update. Maybe give that a go?

Leave a Reply

Your email address will not be published. Required fields are marked *