Monday, November 22, 2010

NFS [ Network File System]


NFS [ Network File System]

                         To share the data on one computer with other computer NFS is used.
The Network File System (NFS) was developed to allow machines to mount a disk partition on a remote machine as if it were a local disk. It allows for fast, seamless sharing of files across a network. There are other systems that provide similar functionality to NFS e.g. Samba provides file services to Windows clients.
For Username and Password if we share “/etc/passwd” file on NIS server to clients then they can login to the server but cant get their home directory on server. For that configure that server as NFS and mount the home directory of the user. For that give command :

# mount -t nfs (server's ip address):/home /home
here “:/home” this directory is of server and “/home” is of client.

There is a file at “/etc/” named “exports”
Edit that file... #vim /etc/exports

make changes as...
(name of directory to be shared)     (Ip address of machine whom you want to share directory)    (rights, sync/async)

e.g. /dbc * (rw, async)

here /dbc is the directory on server which we want to share
' * ' means share for all machines ( or you can give specific Ip)

Now to share it give command :
# exportfs -a
# exportfs                    ( To see what is shared on your machine )

To share a directory on your machine which is currently on other machine
make any directory on root for e.g.
# mkdir /abc
# service nfs start
Then mount directory which is on other computer onto your computer for that give command-
# mount -t nfs (client's IP address):s1 /abc

Modes :
async : This mode is fast working because, if someone is accessing a file on a machine and after some processing he changed that file and saved it, but before saving it on to hard disk some other person requested to access that file then in that case also the file is made available for new client without saving that file. But if meanwhile machine gets restarted or network gets off then the file gets lost or corrupted.

Sync : in this mode working is slow because, file gets saved on hard disk first and then made available for the client machine.

no_wdely : If we have selected the 'async' mode then we cannot use this mode.
In this case if 2 users wants to access a single file simultaneously then it is made available for both users and when one user makes changes to that file the changes are reflected only after saving the file by first user.

nohide : if we mount any directory from samba server using nfs it is there in hidden format ( it is due to file system), then instead of mounting filesystem separately to each client just mount filesystem on NFS server and use “nohide” option, the data will gets directly available.

no_subtree_check : if we use this option it will not show directory tree list to client. They have to check it by browsing each directory separately.

insecure_locks : if following options are selected the directory security will not be maintained-
a) no_auth_nlm : authentication is not required for access
b) no_acl : Permissions on file are not checked by server.
c)Mountpoint = path : if we have alredy mounted a directory from some where else we can remount it using nfs.

User Id mapping :

a) root/squash : 'root' is also considered as an anonymous user. It does not have full rights because of security concern.
b) no_root_squash : root is having access as a root user.
c)all-squash : all users will get access as anonymous user.
d)anonuid and anongid : it can map anonymous user and groups id's.
e)insecure : we can not check permissions and other parameters.

If you want a persistent mounting then edit /etc/fstab and make changes as

(ip address of server):/directory_name /path_where_to_mount_directory nfs defaults 0 0

save and exit

It will be helpful if server is having users and their home directories. Give entry of above line in every clients /etc/fstab file. After login every client will gets his home directory.

To make on the service after every reboot give command :

# chkconfig nfs on

No comments:

Post a Comment