Beruflich Dokumente
Kultur Dokumente
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 clients 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
This post will make some comparisons between NFSv4 and NFSv3, and introduce how
to migrate from NFSv3 to NFSv4.
As we all aware, NFSv4 is not just a simple protocol evolution of NFSv3. It has been fully
redesigned to overcome the limitations of its predecessors.
b) Choose an existing directory which will be used as virtual root for. Example: /home/ .
In the following examples, /exports is used as the virtual root.
3. Data migration to the virtual root
Once we have a virtual root, we need to move data exported from the NFSv3 virtual root, as
defined previously. There are two main possibilities:
A.Copy or move data from its path to the virtual root (recommended):
# mv /myshare /exports/myshare_v4
# mv /distros /exports/distros_v4
B.Move the data path sub tree to the virtual root (recommended):
# mkdir /exports/myshare_v4
# mount -bind /myshare /exports/myshare_v4/
# mkdir /exports/distros_v4/
# mount -bind /distros /exports/distros_v4/
4. Modifying export options
The goal is to convert the NFSv3 export options into NFSv4 ones. Most of the NFSv3 and
NFSv4 options are the same (though NFSv4 requires an additional option to exportfs to provide
the virtual root).
1)Virtual root export
#exportfs -ofsid=0,insecure,no_subtree_check *:/exports
2) Exporting subdirectories of the virtual root
# exportfs -orw,nohide,insecure,no_subtree_check *:/exports/myshare_v4
# exportfs -orw,nohide,insecure,no_subtree_check *:/exports/distros_v4
5.Mounting
With the previous configuration and examples, the following commands would be used:
# mkdir /mnt/nfs_v4_root
# mount -t nfs4 10.182.121.238:/ /mnt/nfs_v4_root
# echo $?
0