Monday, July 8, 2013

How to configure nfs


NFS Configuration Command

 

 

NFS = Network File System

Share File or Directory/Folder in Server PC:

In Server PC:

# mkdir /test20
# vim /etc/exports
  test/20    192.168.0.43(rw)        [Only this ip will get shared]
  or
  test/20    192.168.0.0/24(rw)        [all ip will get shared under this network]
  or
  test/20    example.com(rw)            [all ip will get shared under this domain]
  :wq!
# service nfs restart                                                        [service will be restart. N.B: some service will 
                                                                                       failed, need second time this command]
# service nfs restart
# chkconfig nfs on
# showmount -e localhost

 

There are three process in client pc to show or mount or connect with server.

Process: 1 In Client PC:

# showmount -e 192.168.0.1                     [server ip]
# mkdir /xyz                                               [create a folder /xyz under root directory]
# mount -t nfs 192.168.0.1:/test20 /xyz     [shared file will be mount in /xyz directory]
# df -h                                                        [show mount device]
# cd /xyz

Process: 2 In Client PC: this process is called direct mapping.

- At first you have to install a package. Name of this package is 'autofs' (please install the package & run this service)
# service autofs status
# cd /net
# ls
# cd 192.168.0.1              [server ip]
  or
# cd example.com            [domain name]
# vim /etc/fstab
  192.168.0.1:/var/test20    /mnt    /nfs    defaults    0 0
  :wq!
# grep TIMEOUT /etc/sysconfig/autofs    [show time out information. By default 5 minute later it will be time out. you may customize it]
# vim TIMEOUT /etc/sysconfig/autofs   
  timeout=600                                            [I extend 600 second. thats means 10 minute]
  :wq!

Process: 3 In Client PC: this process is called indirect mapping.

# vim /etc/auto.master
  /abc    /etc/auto.abc
  :wq!
# vim /etc/auto.abc
  public    -rw    192.168.0.1:/test20        [server ip & shared file location in server]
  :wq!
# service autofs reload
# cd /abc                                                 [go to /abc]
# ls                                                          [show listing file, you will show nothing]
# cd /public                                             [go to /public]
# ls                                                          [show listing file, you will show shared file]   

No comments:

Post a Comment