search by tags

for the user

adventures into the land of the command line

vagrant synced folders

I actually didn’t realise this until last week (because I don’t read enough) but there’s actually more than one way to sync folders to a vagrant guest. I was tripping up because an ubuntu box I was using wasnt syncing files live when I updated those same files on the host. But a separate centos box was syncing files perfectly..

So.. it was because the ubuntu box was using rsync to sync the files and the centos box was using the default vboxsf.

Which got me thinking I should write this down for next time when I get tripped up…

vboxsf

config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", owner: "root", group: "root"

if you use vboxsf and either nginx or apache, you need to turn of sendfile or your webpage won’t refresh css, js, html files when you edit them on your host:

nginx:

sendfile off;

apache:

EnableSendfile Off

rsync

config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", type: "rsync"

This one made me think something was broken, but it’s just because I didn’t read the instructions. You need to open a new tab and start the rsync

$ vagrant rsync-auto

Then your files will update in the guest when you edit them on the host.

nfs

If you are dev-ing something nodejs, vboxsf and rsync will unveil a tangible lagginess that is only obvious when working with a bajillion files.

If you need to improve the speed, try nfs. I never really tried to use it, but the docs can explain them better.

config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", type: "nfs"

smb

There’s also SMB, but I’m not interested.