(Inspired by http://yourmacguy.wordpress.com/2012/06/29/osx-automount/)
- I have a lot of vagrant projects
- Each of them provides an NFS-Server exporting
/home/vagrant
- Since Mac OS 10.8 the handy "NFS Mounts" from Disk Util are gone
- I'd like a single place, in which I could copy'n'paste a config for a new box and/or comment a box (when I don't need it for some time)
- I'd like to make this a vagrant plugin
- Ideally, the mount will be activated/deactivated when starting/suspending a box
- Edit your
/etc/auto_master
file and add:/Users/<your_user_name>/mounts /Users/<your_user_name/etc/automounts
- Create an empty directory
/Users/<your_user_name>/mounts
and file/Users/<your_user_name/etc/automounts
- For a box create an entry like this in your
automounts
file:
project_x -fstype=nfs,nosuid,browse,bg,intr,soft,nonegnamecache,deadtimeout=1 33.33.33.33:/home/vagrant
This will configure a soft, background nfs-mount of33.33.33.33:/home/vagrant
on/Users/<your_user_name>/mounts/project_x
- Invoke
sudo automount -vc
to reload (and activate) autoload config
- Can pass all
mount
options (such assoft
which helps Finder not to hang when the box is hanging/reloading...) - Can tell where to mount things
- automount is a performance killer
- Each change (adding, removing a mount point) requires a
sudo
which somehow eliminates the possibility to use it as a middleware
AppleScript allows users to "Connect to Server" (pretty much the same thing as invoking cmd-K
in Finder).
This script will mount the same share as above on /Volumes/vagrant
.
osascript -e 'try
mount volume "nfs://33.33.33.33/home/vagrant"
end try'
- Does not need
sudo
-> can be used as automated mount/unmount
- Cannot pass any options
- slows down
vagrant up
when the box has not (yet) started it's nfs-server or has hiccups (suspend while changing networks)