≡ Menu

Linux Beginners Guide to NFS Mount Using Exportfs

Using NFS (Network File System), you can mount a disk partition of a remote machine as if it is a local disk. This article explains how to export a file system to a remote machine and mount it both temporarily and permanently.

1. Export File System to Remote Server using exportfs

To export a directory to a remote machine, do the following.

exportfs REMOTEIP:PATH
  • REMOTEIP – IP of the remote server to which you want to export.
  • : – delimiter
  • PATH – Path of directory that you want to export.

2. Mount Remote Server File System as a Local Storage

To mount the remote file system on the local server, do the following.

mount REMOTEIP:PATH PATH

Explanation

  • REMOTEIP – IP of the remote server which exported the file system
  • : – delimeter
  • PATH – Path of directory which you want to export.

3. Unmount Remote File System

Umount the remote file system mounted on the local server using the normal umount PATH. For more option refer to umount command examples.

4. Unexport the File System

You can check the exported file system as shown below.

# exportfs
/publicdata	webserver.pq.net

To unexport the file system, use the -u option as shown below.

# exportfs -u REMOTEIP:PATH

After unexporting, check to make sure it is not available for NFS mount as shown below.

# exportfs

5. Make NFS Export Permanent Across System Reboot

Export can be made permanent by adding that entry into /etc/exports file.

# cat /etc/exports
/publicdata 	webserver.pq.net

6. Make the Mount Permanent Across Reboot

mount can be made permanent by adding that entry into /etc/fstab file.

# cat /etc/fstab
webserver.pq.net:/publicdata    /mydata   ext3    defaults   0 0
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • MfM October 13, 2010, 7:51 am

    “webserver.pq.net:/publicdata /mydata ext3 defaults 0 0”
    Regarding ext3 in the fstab line: are you supposed to know the remote filesystem? Or is it an indication of the local filesystem you want to use? Shouldn’t it be nfs instead of ext3 or whatever else?

  • Johan Volkers October 13, 2010, 8:31 am

    As far as I know
    webserver.pq.net:/publicdata /mydata ext3 defaults 0 0
    is not correct
    It should be
    webserver.pq.net:/publicdata /mydata nfs defaults 0 0

    Or even better

    webserver.pq.net:/publicdata /mydata nfs intr,soft defaults 0 0

    Omitting intr,soft means the system will hang if webserver.pg.net is not avalable

  • Trax December 31, 2010, 9:51 am

    Hi,

    What about “_netdev” value impact on timeout / no response??

    webserver.pq.net:/publicdata /mydata ext3 defaults _netdev 0

  • yogesh July 20, 2012, 4:41 am

    sir I won 2 know ….. how to work with exportfs -o option…