Skip to content

Mount command to NFS mount the directory in Linux

The mount command in Linux can be used to mount Network File System (NFS) shares. NFS is a protocol that allows files to be shared over a network, similar to how a local file system can be accessed.

Here is the basic syntax for using the mount command to mount an NFS share:

mount [options] [NFS server]:[path on NFS server] [mount point]

[NFS server]: the hostname or IP address of the NFS server (OR YOU SOURCE SERVER FROM WHERE YOU WANT TO READ DATA)
[path on NFS server]: the path of the NFS share on the NFS server
[mount point]: the directory on the local file system where the NFS share will be mounted

For example, if the NFS server has the IP address 172.168.1.100 and the NFS share is located at /nfs/share, to mount the NFS share on local file system at /mnt, you can use the following command:

mount 172.168.1.100:/nfs/share /mnt

Note 1: The mount point should be created before you run the mount command.
Note 2: Also, the NFS server should be configured to export the share that you are trying to mount and the client should have the necessary permissions to access the share.

options that can be used with mount command to mount NFS share include :

-o : to specify various options like rw, ro, hard, soft etc
-t : to specify the file system type
-v : to be verbose

For example, to mount the share in read-only mode and with a soft mount option, you can use the following command:

mount -o ro,soft 192.168.1.100:/nfs/share1 /mnt

For example in our case we use the below command to mount our EBS /utlfile directory from oracle Cloud FSS to have better performance:

mount -t nfs -o \rw,bg,hard,timeo=600,nfsvers=3,tcp,nolock \1.2.3.4:/FileSystem-erp-tst-utlfile /utlfile

Sometimes on any server, we have seen the mount command getting hung, and canceling and restarting nfs services helps it. Although not all the time this is the issue and this is not needed.

/sbin/service nfs restart

 

Brijesh Gogia
Leave a Reply