NFS mount how to

Steps required to do an NFS mount.


Imagine one source host, for instance, that will export its storage /store with read/write permissions to two target hosts, for instance and

I like to use for the target folder the following naming convention

/nfs/<source hostname>

Of course, the target folder must exist on target hosts and it is assumed that there is a route from source to target.

All commands must be run with root privileges.

Source host

Connect to, that is our source host.

NFS service

I assume here that source host has Red Hat OS.

First of all, start NFS service

$ /etc/init.d/nfs start

Make sure the NFS service will start at boot.

$ chkconfig nfs on

Export it

Edit file /etc/exports


After changing configuration launch

$ exportfs -au
$ exportfs -a

To check you are exporting filesystems, launch

$ exportfs

Target host

Connect to, that is one of the target hosts. Then repeat instructions too.

Mount it

Edit /etc/fstab /nfs/ nfs _netdev,noatime,nfsvers=3,rsize=8192,wsize=8192,nocto,intr,bg,rw,soft,actimeo=300 0 0

Check that source host is exporting correctly

$ showmount -e
Export list for

Finally you can mount launching

$ mount /nfs/


$ mount

Don’ t forget a final test, just launch

$ df -h
... 99G  667M   93G   1% /nfs/

Fix listing

After mount, if I do an ls I see something like

$ ls -l /nfs/

drwx------ 4 15111 15110  4096 Mar 11 18:23 dir1
drwx------ 3 15112 15110  4096 Mar 10 18:06 dir2
drwx------ 3 15109 15110  4096 Mar 10 16:23 dir3

I see ids instead of usernames. In the source host I have these entries in the /etc/passwd


Be consistent: keep the same userid on every host.

In this case, I don’t want users can login on target hosts so, I change home and shell entries to /var/tmp/:/sbin/nologin.

So in /etc/passwd on target hosts I have


Now I can see

$ ls -l /nfs/

drwx------ 4 user1   15110  4096 Mar 11 18:23 dir1
drwx------ 3 user2   15110  4096 Mar 10 18:06 dir2
drwx------ 3 user3   15110  4096 Mar 10 16:23 dir3

Yep, the same concept applies to group ids. I need to add this row on /etc/group on target hosts


Et voilà! Listing is fixed

$ ls -l /nfs/

drwx------ 5 user1   grp1  4096 Mar 21 10:05 dir1
drwx------ 3 user2   grp1  4096 Mar 10 18:06 dir2
drwx------ 3 user3   grp1  4096 Mar 10 16:23 dir3