Skip to content

Instantly share code, notes, and snippets.

@rubenclopez
Forked from L422Y/osx_automount_nfs.md
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save rubenclopez/fc7f794665068ecbc443 to your computer and use it in GitHub Desktop.

Select an option

Save rubenclopez/fc7f794665068ecbc443 to your computer and use it in GitHub Desktop.

Revisions

  1. @L422Y L422Y revised this gist Mar 18, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osx_automount_nfs.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ But, upon restart, OS X removes the mount point, and automounting will fail.**

    ## What's the solution?
    It's so easy my jaw dropped when I figured it out.
    Basically, we trick OS X into thinking we're mounting * somewhere else. *
    Basically, we trick OS X into thinking we're mounting **somewhere else.**

    When you're talking about paths in just about any environment, the root folder is the highest path you can reach, whether it's `C:\` (windows) or `/` (*nix)

  2. @L422Y L422Y revised this gist Jan 29, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osx_automount_nfs.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

    Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:
    @@ -20,6 +19,7 @@ Somewhere along the line, Apple decided allowing mounts directly into /Volumes s
    /Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
    Make sure you:

    sudo chmod 644 /etc/auto_nfs

    Otherwise the automounter will not be able to read the config and fail with a `... parse_entry: getmapent for map failed...` error in `/var/log/messages`
  3. @L422Y L422Y revised this gist Jan 29, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions osx_automount_nfs.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@

    I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

    Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:
    @@ -18,6 +19,10 @@ Somewhere along the line, Apple decided allowing mounts directly into /Volumes s

    /Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
    Make sure you:
    sudo chmod 644 /etc/auto_nfs

    Otherwise the automounter will not be able to read the config and fail with a `... parse_entry: getmapent for map failed...` error in `/var/log/messages`

    This will not work (anymore!) though it "should".

  4. @L422Y L422Y created this gist Jan 29, 2014.
    70 changes: 70 additions & 0 deletions osx_automount_nfs.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

    Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

    /etc/auto_master **(see last line)**:

    #
    # Automounter master map
    #
    +auto_master # Use directory service
    /net -hosts -nobrowse,hidefromfinder,nosuid
    /home auto_home -nobrowse,hidefromfinder
    /Network/Servers -fstab
    /- -static
    /- auto_nfs -nobrowse,nosuid

    /etc/auto_nfs **(this is all one line)**:

    /Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share

    This will not work (anymore!) though it "should".

    $ sudo automount -cv
    ...
    automount: /Volumes/my_mount: mountpoint unavailable


    **Note that, if you manually create the mount point using `mkdir`, it will mount.
    But, upon restart, OS X removes the mount point, and automounting will fail.**


    ## What's the solution?
    It's so easy my jaw dropped when I figured it out.
    Basically, we trick OS X into thinking we're mounting * somewhere else. *

    When you're talking about paths in just about any environment, the root folder is the highest path you can reach, whether it's `C:\` (windows) or `/` (*nix)

    When you're at this path, attempting to reach the parent path, via `..` will keep you at the root path.

    For example: `/../../../../` is still just `/`

    By now, a few of you have already figured it out.

    ## TL;DR / Solution:

    Change your `/etc/auto_nfs` config from **(this is all one line)**:

    /Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share

    To **(this is all one line)**:

    /../Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share


    And re-run the automounter:


    $ sudo automount -cv
    ...
    automount: /Volumes/my_mount: mounted

    ..... there you go! Technically `/../Volumes` is still `/Volumes`, but the automounter does not see things that way ;)

    This configuration persists the mount across restarts, and creates the mountpoint automatically.

    # I KNOW, RIGHT?

    Feel free to send me large checks and/or high five the screen.
    [email protected]