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
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s