|
NFS is a tool for sharing directories of files between Windows &Unix File system by multiple users on the same subnet.
Commands
Exportfs -r Refreshes the server’s share list after modifying /etc/exports
Exportfs -v Displays a list of the shared directories and options on a server.
Exportfs -a Exports all shares listed in /etc/exports
Exportfs -u Un exports the share
Showmount -e Hosts shows the available shares on host
Services
Portmap, rpc.nfsd and rpc.mountd are required to run an NFS Server
Services
/etc/init.d/nfs [ start stop status ]
Or
Service portmap status
Service nfs status
Rpcinfo -p <Ip Address > => To verify that these services are running on server or remote server
Portmap => It maps call made from other machines to correct RPC service
Nfs => It translates NFS requests into requests on the local filesystem
Rpc.mountd => It mounts & unmounts filesystem
Files
/etc/exports
NFS Server
Exported directories are defined in /etc/exports
Example of /etc/exports
/data 192.168.10.0/255.255.255.0 (sync) => It means folder data in server shares the content for network [ 192.168.10.0/255.255.255.0 ]
/backup 192.168.1.1 (rw,sync) => It means folder backup shares for the system 192.168.1.1 in read/write mode
Mounting NFS File Systems while System Boots
/etc/fstab
Instead of mount the file system manually by user every time, while system boot the exported files system can be mounted on the local system by configuring in /etc/fstab file.
Syntax for the file/etc/fstab
Hostname:/ITProject/project nfs rsize=8192,wsize=8192,timeo=14,intr
Hostname:/ITProject -> Exported Share @ Hostname
/Project -> Mounting Point
Nfs -> File system
Rsize=8192
The rsize is negotiable between the server and client to determine the largest block size that both can support. The value specified by this option is themaximum size that could be used; however, the actual size used may be smaller.
Note: Setting this size to avalue less than the largest supported block size will adversely affect performance
Wsize=8192
The number of bytes NFS uses when writing files toNFS server. The wsize is negotiated between the server and client to determine the largest block size that both can support. The value specified by this option is the maximum size that could be used; however, the actualsize used may be smaller. Note: Setting this size to a value less than the largest supported block size will adversely affect performance
Timeo
The value in tenths of a second before sending the first retransmission after an RPC timeout. The default value is 7 tenths of a second. After the first timeout, the timeout is doubled after each successive timeout until a maximum timeout of 60 seconds is reached or the enough retransmissions have occured to cause a major timeout.
Then, if the filesystem is hard mounted, each new time- out cascade restarts at twice the initial value of the previous cascade, again doubling at each retransmission. The maximum timeout is always 60 seconds. Better over- all performance may be achieved by increasing the time-out when mounting on a busy network, to a slow server, or through several routers or gateways.
Intr
The mount folder/Project must exist on the client machine before this command can be executed.
Mounting NFS File Systems using autofs
autofs is daemon usually invoked at system boot time control the operation of the automount(8) daemons running on the with the start parameter and at shutdown time with the stop parameter. The autofs script can also manually be invoked by the system administrator to shut down, restart or reload the automounters.
autofs will check the configuration file /etc/auto.master by default to find mount points on the system.
Another file /etc/auto.misc should define mount points /Project directory, this would be defined in the /etc/auto.master file.
The entry in
auto.master It has three fields.
The first field is the mount point.
The second field is the location of the map file.
Third field is optional. The third field may contain the information of like timeout value.
Example for the file auto.master:
Example for the file /etc/auto.misc:
FirstProject --rw,soft,intr,rsize=8192,wsize=8192 sysadmin.nfs.com:/LAMP
The first field in /etc/auto.misc is the name of the /Project subdirectory. This subdirectory is created dynamically by automount.
The second field is contains mount options such as rw for read and write access.
The third field is the location of the NFS export including the hostname and directory.
The directory /project must be existed on the local file system. And there should not be subdirectories in /Project on the local file system.
To start the autofs service, at a shell prompt, type the following command:
/sbin/service autofs restart
To view the active mount points, type the following command at a shell prompt:
/sbin/service autofs status
If you modify the /etc/auto.master configuration file while autofs is running, you must tell the automount daemon(s) to reload by typing the following command at a shell prompt:
/sbin/service autofs reload
NFS Options
Content of file /etc/exports
If allow connection from Port 1034 and higher tab is selected
/data 172.25.25.102(rw,insecure,async,nohide)
If allow connection from Port 1034 and higher tab is not selected
/data 172.25.25.102(rw,async,nohide)
/data/test 192.168.1.200(rw,async,no_subtree_check,nohide)
/data/test 192.168.1.200(rw,async,subtree_check,nohide)
Sync write operations on request — Enabled by default, this option does not allow the server to reply to requests before the changes made by the request are written to the disk. This option corresponds to sync. If this is not selected, the async option is used.
/data/test 192.168.1.200(rw,sync,nohide)
/data/test 192.168.1.200(rw,async,nohide)
Force sync of write operations immediately — Do not delay writing to disk. This option corresponds to no_wdelay.
/data/test 192.168.1.200(rw,sync,no_wdelay,nohide)
The User Access tab allows the following options to be configured:
Treat remote root user as local root — By default, the user and group IDs of the root user are both 0. Root squashing maps the user ID 0 and the group ID 0 to the user and group IDs of anonymous so that root on the client does not have root privileges on the NFS server. If this option is selected, root is not mapped to anonymous, and root on a client has root privileges to exported directories. Selecting this option can greatly decrease the security of the system. Do not select it unless it is absolutely necessary. This option corresponds to no_root_squash.
/data/test 192.168.1.200(rw,sync,no_wdelay,nohide,no_root_squash)
data/test 192.168.1.200(rw,async,nohide)
Treat all client users as anonymous users — If this option is selected, all user and group IDs are mapped to the anonymous user. This option corresponds to all_squash.
Specify local user ID for anonymous users — If Treat all client users as anonymous users is selected, this option lets you specify a user ID for the anonymous user. This option corresponds to anonuid.
Specify local group ID for anonymous users — If Treat all client users as anonymous users is selected, this option lets you specify a group ID for the anonymous user. This option corresponds to anongid.
|