Wednesday, 28 January 2015

The Simple Setup of NFS On Single Device.

About NFS:

  

Set up NFS on Single Device:

OS: Ubuntu 14.04

1:  Install packages :
       sudo apt-get install nfs-kernel-server portmap

2:  Choose which Directory to be shared.
     suppose, we want to share  /home/youandme
     if there is no directory of youandme...
     you can create it:
                 sudo -s
                mkdir /home/youandme
 
        check by :  ls /home

3:  Permissions:
        give permissons
            chown  nobody:nogroup  /home/youandme

 4: Registor the directory to exports:
                  
        nano /etc/exports
       
      
       -file is opened.. add below line at end of file.
      
         /home/youandme  127.0.0.1(rw,sync,no_root_squash,no_subtree_check)

       - press ctrl+O to save
       -  Enter
       - press ctrl+X to exit. 
  5:    In above line.
       -    /home/youandme is directory to be shared.
       -   127.0.0.1 is ip of ur laptop/pc 
              -  u can get it by:
                       
                           ifconfig

               -  find inet addr: 127.0.0.1    (something like this..)
         -  U can also give only ur Username instead of 127.0.0.1 
                         like..  my username is matrix.
                      /home/youandme  matrix(rw,sync,no_root_squash,no_subtree_check)

         - (rw,sync,no_root_squash,no_subtree_check) are the serveral tasks:
                  rw  - read and write in shared directory.
                  sync - confirms request to shared directory only the changes have been committed.
                  no_subtree_check  -  this option prevents the subtree checking.
                  no_root_squash  - this allow root to connect to designated directory.

 6:  Run the following command to export the file:
         
             exportfs -a

///@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                         
                                            ......INTERVAL....

//############################################################
 below commands can be done on different Computer or Same.

7:  apt-get install nfs-common portmap    //client setting..
8:   create the directory or choose the directory, where u would want to see the shared file.
         suppose i want to see all /home/youandme file  in  /home/friends
           create /home/friends :      
                                  mkdir -p  /home/friends

 9:   finally mount..
            mount 127.0.0.1:/home/youandme   /home/friends


//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   
you can check it by 
           df    -h
10:     TEST: 
                 create one file in /home/youandme
   
                 check in /home/youandme   AND ... it will be in /home/friends also..!!
           
      
//##############################################################
11:   u can keep this mount active by adding the directory to fstab.
            
                   nano /etc/fstab

          - file opened... add below line.
           
     127.0.0.1:/home/youandme   /home/friends  nfs  auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo = 1800 0 0
                  
                                             
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

12: To  Remove the mount do as follow:
              cd
              sudo umount /home/friends

         - check by 
            
               df -h


//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                                     THE END.