Table of Contents

NFS - How to Use NFS in Linux



Abount NFS


Check NFS Version

Server

# rpcinfo -p | grep nfs
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
#

Client

# nfsstat -m
/reports from 192.168.0.10:/nfs/share/reports
 Flags: rw,vers=3,rsize=524288,wsize=524288,soft,intr,proto=tcp,timeo=600,retrans=2,sec=sys,addr=192.168.0.10

#mount
nfs-server:/vol/test on /home/test type nfs (rw,hard,intr,vers=4,addr=192.168.0.10,clientaddr=192.168.0.11






Configuration of Server

Services

# /etc/init.d/portmap start
# /etc/init.d/nfs start

Configuration /etc/exports

/home/public    client1(rw,no_root_squash)         # Permit root access
/home/pub       192.168.1.0/255.255.255.0(ro)
/mnt/cdrom      *(ro)
/home/public    client1(rw,no_root_squash)  client2(rw,no_root_squash)

export options

Option Notes
ro Permit read only
rw Permit read and write
root_squash Default Option
no_root_squash Permit root access
timeo=n Default is 7 (0.7sec)
retrans=n Default is 3

reflect configuration

checkinng NFS configuration.

# exportfs -v

Reflect configuration.

# exportfs -a 
# exportfs -r






Configuration of Client

Services

# /etc/init.d/portmap start

mount

mount by hand

mount  -t  nfs  192.168.0.100:/home/public  /mnt/public

automatically mount

/etc/fstab
192.168.0.100:/home/public  /mnt/public   nfs   rw,hard,intr   0       0

mount options

Option Notes
hard
soft
intr

/etc/init.d/netfs

If you start OS, nfs automatically start. If you stop os, and nfs automatically umount.

chkconfig netfs on




autofs