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 exportfsTo export a directory to a remote machine, do the following.
- 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 StorageTo mount the remote file system on the local server, do the following.
mount REMOTEIP:PATH PATHExplanation
- 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 SystemUmount 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 SystemYou can check the exported file system as shown below.
# exportfs /publicdata webserver.pq.netTo unexport the file system, use the -u option as shown below.
# exportfs -u REMOTEIP:PATHAfter unexporting, check to make sure it is not available for NFS mount as shown below.
5. Make NFS Export Permanent Across System RebootExport 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 Rebootmount can be made permanent by adding that entry into /etc/fstab file.
# cat /etc/fstab webserver.pq.net:/publicdata /mydata ext3 defaults 0 0