NFS (Network File System) for Beginners


NFS (Network File System) for Beginners: In this post I am trying to build a base for the beginners. This post will help to proceed further with NFS complex tasks.

What is NFS?

NFS —> Network File System —> The Network File System (NFS) is a client-server service that enables users to view, store, and update files on a remote server as though they were on the their own local server. In Simple layman language NFS provides a “Centralized File Access”.

Example: Suppose you have a 100 users in a company. Out of which 50 require complete access to 10 files/softwares etc. for there daily day to day work and other 50 require access to other commonly used 15 files/softwares etc. for there work. Now instead of placing individual files/softwares on each users server (computer) you should keep the files/softwares in a common shared place which users would have access to. Now each user can access (read/write/modify –> depending upon access provided) those commonly used files/softwares remotely without having them on his/her local server/computer. This will help to save the diskspace as well on all users server.

NFS Model:

========

Server client mode —> NFS is based on Server-C;ient Model. The server where the files are physically stored is called “Master server” and the server which is using thoses files remotely are called “Client server”.

Note: The Solaris 10 OS supports versions 2, 3, and 4 NFS simultaneously. The default is to use NFSv4.

NFS Server Files:

============

/etc/dfs/dfstab —> defines the files/directory to be shared (command used is share), also run shareall command after editing this file. Lists the local resources to share at boot time.

/etc/dfs/sharetab —> shows the result of share command. All share file/dir. will be shown here. Lists the local resources currently being shared by the NFS server. Do not edit this file.

/etc/dfs/fstypes —> Lists the default file system types for remote file systems.

/etc/rmtab —> Contains the table of filesystems remotely mounted by the client. (mountd daemon).

/etc/default/nfs —> parameters for NFS daemons and protocols.

/etc/default/nfslogd —> Lists configuration information describing the behavior of the nfslogd daemon for NFSv2/3.

NFS Server Service:

===============

NFS Server Service: We have to Enable the NFS server service, svc:/network/nfs/server.

# svcs -a | grep -i /network/nfs/server

# svcadm enable /network/nfs/server

# svcs -a | grep -i /network/nfs/server

NFS SERVER DAEMONS:

==================

mountd —> handles clients filesystem mount requests.

nfsd —> client FS request.

statd —> work with lockd for recovery function.

lockd —> recored locking operation.

nfslogd —> Provides operational logging for NFSv2 and 3.

nfsmapid —> NFS users & grps mapping.

NFS SERVER COMMANDS:

===================

share —> shows the shared files (i.e shows the contents of /etc/dfs/sharetab). Makes a local directory on an NFS server available for mounting. It also displays the contents of the /etc/dfs/sharetab file.

unshare —> unshare all. Makes a previously available directory unavailable for client side mount operations.

shareall —> (/etc/dfs/dfstab) —> shows all entries from this file and execute them.

unshareall —> unshare all. Makes previously shared resources unavailable.

dfshares —> show the shared resources.

dfmounts —> Show the currrently mounted FS.

NFS CLIENT FILES:

==============

/etc/vfstab —> Defines file systems to be mounted locally. eg: raheja:/usr/nfstest – /yogeshtest nfs – yes soft,bg

/etc/mnttab –> Lists currently mounted file systems, including automounted directories. The contents of this file are maintained by the kernel and cannot be edited.

/etc/dfs/fstypes —> Lists the default file system types for remote file systems.

/etc/default/nfs —> Contains parameters used by NFS protocols and daemons.

NFS CLIENT DAEMON:

=================

statd —> Works with the lockd daemon to provide crash recovery functions for the lock manager.

lockd —> Supports record-locking operations on NFS files.

nfs4cbd —> callback daemon for NFSv4.

NFS CLIENT COMMANDS:

===================

dfshares —> lists shared resources.

mount —> mount the shared FS. eg: for sharing from single and multiple servers, mount raheja:/usr/nfstest /yogeshtest  and  mount -o ro raheja1,raheja2,raheja3:/multi_homed_data /remote_shared_data

umount —> Unmounts a currently mounted file resource.

mountall —> Mounts all file resources or a specific group of file resources listed in the /etc/vfstab file with a mount at boot value of yes.

umountall —> Unmounts all non-critical local and remote file resources.

==================================================================================

A Simple example to share a file from NFS master server to Client server.

On NFS server:

=============

1.) make one directory as /usr/nfstest.

# mkdir /usr/nfstest

2.) edit /etc/dfs/dfstab file with the shared dir/file info.

# share -F nfs -o ro -d “test NFS sharing” /usr/nfstest

3.) execute share -F nfs /usr/nfstest.

# share -F nfs /usr/nfstest

share [ -F nfs ] [ -o options ] [ -d description ] [ pathname ]

where:

-F nfs Specifies the file system type. This option is not typically required, because NFS is the default remote file system type.

-o options Controls a client’s access to an NFS shared resource.

-d description Describes the shared file resource.

pathname Specifies the absolute path name of the resource for sharing.

4.) share command will show you the output now.

On NFS Client:

==========

5.) On client edit /etc/vfstab

eg: raheja:/usr/nfstest – /yogeshtest nfs – yes soft,bg

6.) Make directory (/yogeshtest) and mount it.

# mount raheja:/usr/nfstest

7.) df -k will show you the shared dir/file now.

Note: 1.) This is the simplest representation of NFS. This will help you to build a base to perform complex NFS tasks. You will find many NFS related issues with their

resolution at our side as we have already posted many posts on NFS.

2.) You can check NFS services running on Server or Client via svcs -a | grep -i nfs.

3.) Kindly refer default files as stated in the post in the server itself for more clarity (eg: cat /etc/dfs/dfstab etc.)

4.) Also it would be more useful to go through the man pages of NFS commands.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: