≡ Menu

Mac Os X: Mount NFS Share / Set an NFS Client

How do I access my enterprise NAS server by mounting NFS filesystem onto my Mac OS X based system using GUI and command line based tools?

Network File System (NFS), a distributed file system protocol developed by Sun Microsystems. NFS is the common for file sharing on NAS server and Linux / UNIX systems like, HP-UX, Solaris, Mac OS X, and
Tutorial details
DifficultyIntermediate (rss)
Root privilegesYes
RequirementsOSX 10.6.x/10.7.x
Estimated completion time10m
others. Mac OS X can be setup as an NFS client to access shared files on the network. Mounting NFS volumes in OS X can be done using following methods:

a] Command line option.

b] GUI option.

Our Sample Setup

        nas01                                   Laptop/Desktop
   +--------------+                           +--------+
   |  UNIX/Linux  |                           | Mac    |
   |    NFS       +---------------------------+ OS X   |
   |   SERVER     |  mount nas01:/mp3 /nfs    | Client |
   +--------------+                           +--------+
         |                                    (192.168.3.100)
     (shared dirs)
         /
         --/Sales
         --/Mp3
         --/Data
         --/wwwroot
   (192.168.3.1)

nas01 allows your users or client compute to access files over a network. Mac OS can mount file system over a network and work as they are mounted locally. This is perfect for sharing files or centralized home directories. See how to setup an NFS server under RHEL / CentOS Linux and Ubuntu Linux here.

How Do I Find Out Shared Directories?

To mount an NFS file system, the resource must be made available on the NAS or NFS server. To verify that resource available open the terminal and type the following command:
$ showmount -e nas01
$ showmount -e nfs-server-ip-address-here
$ showmount -e nas01.lan.nixcraft.net.in

Sample outputs:

Fig.01: UNIX showmount command lists all clients that have remotely mounted a filesystem from NFS server

Fig.01: UNIX showmount command lists all clients that have remotely mounted a filesystem from NFS server

The showmount command show remote NFS mounts (resources).

Mac OS X Nfs mount Command

First, create a directory to mount an nfs share, enter:
$ sudo mkdir /private/nfs
$ sudo mkdir /private/mp3

To mount an NFS file system, enter:
$ sudo mount -t nfs nas01:/mp3 /private/nfs
OR
$ sudo mount -t nfs 192.168.3.1:/mp3 /private/nfs
To mount an NFS file system in read/write mode, enter:
$ sudo mount -o rw -t nfs nas01:/mp3 /private/nfs

Tip: Operation not permitted Error

If you get an error which read as follows:

 192.168.3.1:/mp3 Operation not permitted

Try to mount it as follows with -o resvport command:
$ sudo mount -t nfs -o resvport 192.168.3.1:/mp3 /private/nfs
OR mount an NFS in read/write mode, enter:
$ sudo mount -t nfs -o resvport,rw 192.168.3.1:/mp3 /private/nfs
From the man page:

resvport
Use a reserved socket port number. This is useful for mounting
servers that require clients to use a reserved port number on the
mistaken belief that this makes NFS more secure. (For the rare
case where the client has a trusted root account but untrustwor-
thy users and the network cables are in secure areas this does
help, but for normal desktop clients this does not apply.)

Verify: NFS Is Working or Not

Type the following commands:
$ df -H
$ cd /private/nfs
$ ls -l

Sample outputs (note I've mounted it at /private/mp3/ dir):

Fig.02: UNIX df command

Fig.02: UNIX df command which displays information about total space and available space for NFS

How Do I Copy Files?

Use the cp command:
$ cp /path/to/file.doc /private/nfs/
$ cp -a /path/to/*pl /private/nfs/
$ cp /private/nfs/mp3/*.mp3 ~/mp3

Using the Finder

Note: The following entry "NFS mounts" in the Disk Utility does NOT exist in MAC OS X v10.8+. The following discussion only applies to the older Mac OS X version <= 10.7.x and eariler.

The Finder is the default file manager used on the Mac OS and Mac OS X operating systems that is responsible for the overall user-management of files, disks, network volumes and the launching of other applications. Open Finder > Shared (select from the left sidebar) > NFS server (nas01 or 192.168.3.1):

Fig.03: The Finder in action (browse an NFS share)

Fig.03: The Finder in action (browse an NFS share)


Now, you can copy and paste files as usual.

Recommend mount Command Options

I suggest that you run the mount command it as follows to get better a performance:
$ sudo mount -t nfs -o soft,intr,rsize=8192,wsize=8192,timeo=900,retrans=3,proto=tcp nas01:/sales /private/sales
OR
$ sudo mount -t nfs nfs -o soft,timeo=900,retrans=3,vers=3, proto=tcp nas01:/sales /private/sales
See mont_nfs(8) for more information.

GUI Method: HowTo Set Mac OS X As an NFS Client

To mount an NFS share from OS X using GUI tools, follow these steps:

[1] Start Finder, and go to Applications / Utilities / Disk Utility:

Fig.04: Starting Disk Utility

Fig.04: Starting Disk Utility


You will see the disk utility as follows:

Fig.05: Click the 'Mounts' icon at the top of the Directory Utility panel

Fig.05: Click the 'Mounts' icon at the top of the Directory Utility panel

[2] Alternatively, you can select "Disk utility" > click on File > Mount NFS as follows:

Fig.06: Mounting an NFS using - Disk Utility > File > Mount option

Fig.06: Mounting an NFS using - Disk Utility > File > Mount option


You will see an "NFS mounts" window as follows:
Fig.07: OS X NFS Mounts to set it as an NFS Client

Fig.07: OS X NFS Mounts to set it as an NFS Client


[3] Click on "+" icon:
Fig.08: Setting up an NFS mount options in the dialog box

Fig.08: Setting up an NFS mount options in the dialog box


You need to enter your remote NFS server URL (IP address or dns name) in the following format:
nfs://192.168.3.1/mp3
nfs://nas01/mp3

Where,

  1. 192.168.3.1: NFS server IP address.
  2. nas01: NFS server dns name.
  3. mp3: Shared nfs directory name.

You need to set mount location as follows:
/Volumes/mp3
/Volumes/mp3 is nothing but the mount location. This is a convenient place. In this example, you entered the URL as nfs://192.168.3.1/mp3, enter /Volumes/mp3 as the mount location. Please note that don't create the subdirectory (mp3); it will be created dynamically when the share is mounted.

Optional

Click the arrow in front of "Advanced Mount Parameters". A new text entry box is displayed. Enter: resvport (this is only required if you get some sort of error [see above for more info or read mount_nfs man page]).
[4] Finally, click "Verify" button at the bottom right:

Fig.09: Verify NFS mount configuration which only checks that your NFS server is enabled and working correctly.

Fig.09: Verify NFS mount configuration which only checks that your NFS server is enabled and working correctly.


[5] You will see a popup window, stating that "The NFS server appears to be functional" > Click "OK" button to continue. Finally, Click "Save" button. You may be prompted for the password to make changes. Your NFS share should appear at the mount location you entered above i.e. /Volumes/mp3.
Fig.10: NFS Share mounted

Fig.10: NFS Share mounted

You can access /Volumes/mp3 using the Finder:

Fig.11: The finder in action

Fig.11: The finder in action


You can also use command line options:
$ ls /Volumes/mp3
$ cd /Volumes/mp3
$ cp /path/to/something.file.in file.out
$ rsync -av user@server3.nixcraft.com:/var/www/html/ server.backups/

See also:

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 32 comments… add one }

  • Sergei November 4, 2010, 7:58 am

    now that’s a working tutorial! been struggling with my Zyxel NSA220, trying to use NFS instead of SMB – couldn’t mount until found this page :)

  • Jaysunn December 8, 2010, 9:19 pm

    Wow,
    Vivek this is a great tutorial. I as well was struggling and as soon as I found this page I nailed it in one try. Thanks jaysunn

  • Ken March 30, 2011, 10:48 pm

    This doesn’t describe how to set up persistent NFS mounts from the command line (hard mounts, not automounts). That should be easy but I can’t find it anywhere.

    • nixCraft March 31, 2011, 5:18 am

      Do you want to know about soft / hard option that determines the recovery behavior of the NFS client after an NFS request times out? May be you need to give us more info..

    • dipmit August 2, 2011, 11:54 am

      you have to fire this command for mout NFS shared folder to MAC OX
      sudo mount_nfs -P :

  • erez May 6, 2011, 12:28 am

    Great job……thanks :-)

  • Chiraj September 11, 2011, 10:38 pm

    I followed every step(gui and terminal) word for word and I can see files on my nfs server, but I can’t write or modify the contents of the shared directory. It keeps saying “Permission Denied”. Is there anything particular I need to do on the server side?

    • nixCraft September 12, 2011, 11:36 am

      You need to make sure server is exporting directories in a rw (read write) and not in a ro (read only) mode.

      • Chiraj September 14, 2011, 9:26 pm

        If have tried exporting it as rw as seen below, but still no avail :(

        /mnt/shared 192.168.0.0/255.255.0.0(rw,sync,all_squash,anonuid=502,anongid=502,insecure)

        • sofia story February 7, 2012, 3:42 am

          Same problem here.

          • Colin August 28, 2012, 12:50 pm

            ditto Lion 10.7.4 rw enabled in /etc/exports

  • fsimerey September 14, 2011, 4:18 pm

    Have a NFS server running on Debian 5.
    I can mounting my shares on Linux Mint 11 like a charm (with r/w permissions).
    But under os 10.6.8, i can mount these shares but i haven’t permission to write or modify anything -> “Permission Denied”.
    The NFS server is setup with these options in /etc/exports

    /mnt/shared 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)

    Any idea ?
    Thanks in advance

    • fsimerey September 14, 2011, 4:57 pm

      In fact, i can create and modify files via terminal if i use sudo command or logged as root.
      All folders/files are uid=1000 and gid=1000 like the screen capture of this article.

      • ttt May 7, 2012, 1:52 pm

        You need to add an account on Debian server. For example if you login as fsimerey on OS X. Make fsimerey account on the Debian too. This will map UID and GIDs.

  • Sx1 October 8, 2011, 7:30 pm

    Hi from France,

    Great faqs, thank !
    I have the same question as fsimerey.

    I can access to my nfs server, but not with my single user account under mac Osx. I need to use SUDO into the terminal to access it.

    From my others PC, under Ubuntu, single users don’t needs to use root account to access the nfs.

    My nfs server exports : rw, sync, no_root_squash, anonuid=1000,anongid=1000

    Can you help me please ?

    Thank a lot

  • Lyndon Adams October 18, 2011, 9:02 pm

    Worked first time using Fedora 15 and latest Mac OS X. Many thanks!!

  • pww October 21, 2011, 2:35 am

    got it

  • Nicklas Nilsson January 15, 2012, 4:53 pm

    Same problem as fsimerey and sx1! Anyone now a fix?

    • nixCraft January 15, 2012, 7:21 pm

      Most modern NFS server need some sort of user authentication and user id mapping. For example, /home/vivek is owned by vivek user id # 501 on the Debian Linux nfs 4 server.
      You need to add a user called vivek to Apple OS x with user id # 501 using the following command:

      sudo dscl . -create /Users/vivek UniqueID "501"

      See this page for more info. Use dscl command with care as it can destroy existing users and other system properties.

  • Rogerio January 21, 2012, 5:04 am

    Thanks for the article.
    Now I have a NFS server running on Ubuntu 11.10 exporting a 2TB exFAT external HD drive. Had to install fuse-exfat to be able to mount the HD on Ubuntu.
    I mounted a NFS folder on a Mac OSX using: sudo mount -t nfs -o resvport my_nfs_server:/media/HD2TB /private/nfs and from Finder I can navigate through and create folders and even open large files. The problem is that I can’t copy anything to the NFS (neither from Finder nor from Terminal). Here is the error:
    cp: /private/nfs/test.txt: fchmod failed: Input/output error
    Here is my /etc/exports:
    /media/HD2TB my_mac(rw,no_root_squash,no_subtree_check)
    Thanks for helping.

    • fsimerey January 21, 2012, 10:26 am

      For my nfs exports on Debian, i used insecure option.
      Try with:
      /media/HD2TB my_mac(rw,no_root_squash,no_subtree_check,insecure)

      Hope that would solve your prob.

  • Björn König April 15, 2012, 2:58 pm

    Thanks for the tutorial. It fit the trick for me!

  • tim July 31, 2012, 12:50 am

    running ox 10.8 and in disk utility. Under file menu mount is grayed out and there is no nfs mount in menu.

  • Nik September 2, 2012, 3:13 pm

    Vivek – Brilliant! Was annoyed with my Synology 1512+ shares with AFP going offline and having to remount for my Plex (MMS). This was the solution! I used your tutorial (which was spot on) and a GUI from NFS Manager(now that OSX 10.8 Disk Utility doesn’t have NFS mounting options) and was successful. I’m super happy now with automounts and dismounts for all my shares! Great, great job!!!!

    p.s. With OSX 10.8 not including the Disk Utility bit, you may want to update/mention that for future users.

  • Daniel September 6, 2012, 9:43 am

    After a solid week of having permission denied messages etc.. out of Mountain Lion, here is the fix…..

    Stolen from Apple Discussions:

    Hi!
    Few days ago i run into same problem. I have Ubuntu server and want to mount some folders from there… Anyway, I was solved this problem this way:
    — on Ubuntu —
    1. edit /etc/exports (sudo vim /etc/exports) and add this line(s)

    /folder 0.0.0.0(rw,sync,all_squash,insecure,anonuid=xxx,anongid=xxx)
    


    where “/folder” is a folder you want to mount from your Mac
    “0.0.0.0” is an IP address you allow to connect to your share from
    “anonuid=xxx,anongid=xxx” is UID and GID of user on Ubuntu you want to be used as owner of files you want to create on mounted share (if you ommit this you will have read-only access to the share folder)
    2. export your shares – sudo exportfs -a
    ———————–
    — on your Mac —
    Use Connect to Server (Commant+K) menu and write nfs://server-name-or-ip/folder
    ————
    Voila! You have to have rw access to shared folder on your server.

    P.S. check man exports to find some additional info to set IP ranges you want to allow to connect from.

    Good luck!

  • Ulf von Barth May 25, 2013, 11:00 am

    Dear Helper,

    There are two major flaws with the mount instructions above:
    1. The entry “NFS mounts” in the Disk Utility does NOT exist in MAC OS X 10.8!
    2. It is easy to NFS-mount disks read only in 10.8 but much harder to mount them
    read-write. As you can see above the parameter “-o rw” is missing in the
    examples above!

    Thanks anyway for the nice tutorial. Have a good day, vonbarth

    • nixCraft August 4, 2013, 8:41 am

      Thanks for the heads up! The faq has been updated.

  • Steve Glasser May 29, 2013, 3:09 am

    Vivek — there is a problem accessing a “normal” nfs server from osx if the mount option “-o resvport” is used on the osx client. Most/normal nfs servers are firewalled; opening port 2049 for nfs connections. Osx is going to pick a random low-numbered port to connect on and this will be blocked on the nfs server.

    Is there some sort of solution for this? Cheers

  • Matheus October 1, 2013, 2:13 pm

    I has no problem at all setting up a NFS client for my macOsx 10.8…. The only thing is that diskutil does not support it but terminal does!

  • Klas Wirholm March 1, 2014, 4:06 am

    The problem is the dynamic port the mac client try to access. For you who have a Linux nfs server, this is probably is off interests.

  • remd September 8, 2014, 8:55 am

    I’ve setup a freeipa server on centos mostly following theses guidelines:
    http://linsec.ca/Using_FreeIPA_for_User_Authentication#Mac_OS_X_10.7.2F10.8

    Everything seems to be working fine, except that the osx client can’t automount the /home share at startup.
    I can auth and/or mount the share manually in the command line, but at startup the logs show “server not responding”.
    This is the line I’ve added in auto_home (referred to in auto_master):
    * -fstype=nfs,rw,resvport,soft,intr,rsize=8192,wsize=8192,nosuid,tcp nfsserver:/home/&

    I have tried many options and variations of this command, but have been unsuccessful so far – does anyone have an idea how this can be done ?

  • remd September 9, 2014, 1:42 pm

    It was a firewall issue – its working now

Leave a Comment