Recent Changes - Search:

Softwares

.

How-to-configure-NFS-The-Network-File-System

The network file system is based on RPC:

Which allows the client to auto mount and access the file system. In RPC subroutines are executed on another address space, say on another computer.

[root@wordsworth ~]# cat /proc/filesystems

Softwares that are needed.

  [root@wordsworth ~]#  rpm -qa | grep nfs
  nfs-utils-lib-1.0.6-8
  nfs-utils-1.0.6-80.EL4
  system-config-nfs-1.2.8-1
  [root@wordsworth ~]# rpm -q portmap
  portmap-4.0-63
  • RPC portmap package is needed.
  • Configuring NFS on The Server: The /etc/exports file is the main NFS configuration file, and it consists of two columns. The first part lists the networks or DNS domains that can get access to the directory, and the second part lists NFS options in brackets.

Server exports file

All NFS server exports need to be defined in /etc/exports file.

  #/etc/exports
  /data/itmission             *(ro,sync)
  /home                       192.168.0.0/24(rw,sync)
  /data/itmission1            *.itmission.org(rw,sync)
  /data/itmission2            192.168.1.203/32(rw,sync)

/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will not be treated as a root but as a default nfs user.

  • Read-only access to the /data/itmission directory to all networks
  • Read/write access to the /home directory from all servers on the 192.168.1.0 /24 network, which is all addresses from 192.168.1.0 to 192.168.1.255
  • The sync option to ensure that file data cached in memory is automatically written to the disk after the completion of any disk data copying operation.

Service needed to start:

  • nfs, RPC, portmap, nfslock (NFS file locking to reduce the risk of corrupted data.)
   # chkconfig --level 35 nfs on
   # chkconfig --level 35 nfslock on
   # chkconfig --level 35 portmap on

Start

  [root@wordsworth ~]# service portmap start
  Starting portmap:                                          [  OK  ]
  [root@wordsworth ~]# service nfs start
  Starting NFS services:                                     [  OK  ]
  Starting NFS quotas:                                       [  OK  ]
  Starting NFS daemon:                                       [  OK  ]
  Starting NFS mountd:                                       [  OK  ]
  [root@wordsworth ~]# service nfslock start
  Starting NFS statd:                                        [  OK  ]
  [root@wordsworth ~]#

Check if running or not

[root@wordsworth ~]# rpcinfo -p localhost

   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100011    1   udp    881  rquotad
    100011    2   udp    881  rquotad
    100011    1   tcp    884  rquotad
    100011    2   tcp    884  rquotad
    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
    100021    1   udp  37666  nlockmgr
    100021    3   udp  37666  nlockmgr
    100021    4   udp  37666  nlockmgr
    100021    1   tcp  59071  nlockmgr
    100021    3   tcp  59071  nlockmgr
    100021    4   tcp  59071  nlockmgr
    100005    1   udp    897  mountd
    100005    1   tcp    900  mountd
    100005    2   udp    897  mountd
    100005    2   tcp    900  mountd
    100005    3   udp    897  mountd
    100005    3   tcp    900  mountd
    100024    1   udp    932  status
    100024    1   tcp    935  status

[root@wordsworth ~]#

On Client Machine.

  [root@wordsworth ~]# service netfs start
  Mounting other filesystems:                                [  OK  ]
  [root@wordsworth ~]# service portmap start
  Starting portmap:                                          [  OK  ]
  [root@wordsworth ~]# service nfslock start
  Starting NFS statd:                                        [  OK  ]

Mounting NFS with fstab

  #/etc/fstab
  #Directory                    Mount Point            Type     Options       Dump   FSCK
  192.168.0.1:/data/itmission   /media/itmission        nfs    soft,nfsvers=2  0      0

or

  echo "192.168.0.1:/data/itmission  /media/itmission  nfs  defaults 0  0" >> /etc/fstab

Manually Mounting NFS File Systems:

  mount -t nfs 192.168.0.1:/data/itmission /media/itmission

Stats

   [root@wordsworth ~]# nfsstat -s
   Server rpc stats:
   calls      badcalls   badauth    badclnt    xdrcall
   0          0          0          0          0

   [root@wordsworth ~]# cat /etc/services |grep nfs
   nfs             2049/tcp        nfsd
   nfs             2049/udp        nfsd
   [root@wordsworth ~]#

   [root@wordsworth ~]# cat /etc/services |grep portmap
   sunrpc          111/tcp         portmapper      # RPC 4.0 portmapper TCP
   sunrpc          111/udp         portmapper      # RPC 4.0 portmapper UDP
   rpc2portmap     369/tcp
   rpc2portmap     369/udp                         # Coda portmapper
   [root@wordsworth ~]#

Restart NFS daemon or run command exportfs:

   exportfs -ra

Telnet check

  [root@wordsworth ~]# telnet localhost 2049
  Trying 127.0.0.1...
  Connected to localhost (127.0.0.1).
  Escape character is '^]'.
  help
  Connection closed by foreign host.

  [root@wordsworth ~]# telnet localhost 111
  Trying 127.0.0.1...
  Connected to localhost (127.0.0.1).
  Escape character is '^]'.
  help
  ^]
  telnet> q
  Connection closed.
  [root@wordsworth ~]#

NMAP check

   [root@wordsworth ~]# nmap localhost

   Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2007-08-12 20:23 IST
   Interesting ports on localhost (127.0.0.1):
   Not shown: 1668 closed ports
   PORT     STATE SERVICE
   21/tcp   open  ftp
   22/tcp   open  ssh
   53/tcp   open  domain
   80/tcp   open  http
   111/tcp  open  rpcbind
   139/tcp  open  netbios-ssn
   445/tcp  open  microsoft-ds
   884/tcp  open  unknown
   900/tcp  open  unknown
   935/tcp  open  unknown
   2049/tcp open  nfs
   3306/tcp open  mysql

   Nmap finished: 1 IP address (1 host up) scanned in 0.321 seconds
   [root@wordsworth ~]#

Man Pages:

  [root@wordsworth ~]# man -k exports
  exports              (5)  - NFS file systems being exported (for Kernel based NFS)
  [root@wordsworth ~]# man -k rpcinfo
  rpcinfo              (8)  - report RPC information

Reference:

Edit - History - Print - Recent Changes - Search
Page last modified on August 12, 2007, at 02:58 PM