5

I am new to using Apple as main OS. I am used to fstab in Linux to keep the mounts for nfs. When I use Go to in Finder to mount nfs://serveripaddress/home/shared I get a permissions error.

The below command works from Terminal though:

    mount -t nfs -o resvport,nolocks,locallocks,intr,soft,wsize=32768,rsize=3276 \
        serveripaddress:/home/shared /private/shared

How can I get this to be mounted each time I log in and vpn to the network where this share resides?

2
  • Currently I have resorted to a shell script in my documents folder that when run will mount the desired drives. Sep 30, 2013 at 11:54
  • I am also grappling with NFS - see my answer to your question below. Could you please explain the mount options in your example and why you're using them?
    – starfry
    Oct 8, 2013 at 8:57

2 Answers 2

10

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

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?

0
0

I am also new to OSX. This is how I mounted my Linux share. I used sudo vifs which is apparently the OSX preferred way to edit /etc/fstab. I then entered a mount stanza like the below:

myserver:/path/to/files /Users/me/files nfs resvport,bg,async,nfc 0 0

This works and the mount happens automatically. However I am suffering from the famous show-performance-in-finder issue (copying to server fast on command line but excruciatingly slow in finder).

The mount options I used are:

  • resvport - needed to use a low port as expected by Linux server
  • bg - the mount will be silently retried in the background if unsuccessful
  • async - my attempt to increase performace. man mount_nfs and read the risks.
  • nfc - makes UTF-8 characters work properly (man mount_nfs)

For completeness, here is the server-side configuration in /etc/exports:

/home/me/files 10.20.30.40(rw,sync,all_squash,anonuid=1000,anongid=100)

Here, 10.20.30.40 should be the IP of the OSX client (assuming you want to restrict the export to that client). My Linux uid/gid are 1000/100. I've used all-squash to convert uid/gid to those I have on Linux because of the OSX differences. This isn't a perfect way to do this but it meets my immediate needs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .