Sharing the file system
exportfs is the command that is used to export the directories, files and filesystem to the clients. exportfs command makes local directories available for NFS (Network File System) clients to mount. This command is generally invoked in during system startup through the run level 3 and uses information in the /etc/exports file to export one or more directories that must be specified with full path names.
The /etc/rmtab file lists directories which are presently exported. To show this file, the exportfs command has to be entered without flags or arguments. For alter the file or to alter the features of one of its directories, root users can edit the /etc/exports file and run the exportfs command.
CAUTION
Never edit the/etc/rmtab manually.
Note: /etc/rmttab is the file. That lists directories that are currently exported.
Syntax
exportfs [ options ]
options
-a Exports all directories which are listed in the /etc/exports file.
-v Prints the name of every directory as it is unexported or exported.
-u Unexports the directories which are specified. Whenever used with the -a flag, unexports all directories listed in the /etc/exports file.
-I permit the exporting of directories not specified in the exports file or ignore the options in the /etc/exports file. Generally the exportfs command consults the /etc/exports file for the options related with the exported directory.
-f file Specifies an export file, except the /etc/exports file, which contains a list of directories which can be exported. This file should follow the similar format as the /etc/exports file. NOTE: This instead file will not be used for exporting directories automatically whenever the system and NFS is begin. The /etc/exports file is the only file which is supported for specifying directories to export at system start.
-o options Specifies optional features for the exported directory. More than one variable can be entered through separating them with commas.
Ro Exports the directory with read-only permission. Or else, if not specified, the directory is exported along with read-write permission
Rw = Client [:Client] Exports the directory with read-write permission to the machines specified through the Client parameter and read-only to all others. A Client parameter can be either the host name or the network name. The directory is exported with read-write permission to all if an rw host name is not specified.
/etc/exports format:
# vi /etc/exports
[directory] manchine1[option] machine2[option]
/home/Krishen radiant1(rw) radiant2(ro)
In the given instance the directory called /home/Krishen is available to the hosts radiant1 and radiant2. Intended for radiant1 the access is both read and writes and for radiant2 the access is only for reading. Following the entry is made the nfs services have to be restarted again. These services are generally begun at boot time through the run level3.Given services could also be run manually to stop and start the nfs system. For stop nfs, the user will have to log in as root and enter the next:
Let consider the following example and could be used to start and stop nfs daemons
# /etc/rc.d/init.d/nfs stop
The nfs services can be begins as follows:
# /etc/rc.d/init.d/nfs start
The given command can be used to check whether the nfs daemons are presently running:
# /etc/rc.d/init.d/nfs status
One time an entry is made in /etc/exports file to share the directory; this command has to be run to check whether the directory is shared.
The given example displays how to user the exportfs command.
# exportfs
/home/Krishen radiant1
/home/rams radiant2
In the example /home/Krishen is exported to radiant1 and /home/rams is exported to radiant2
To export entries in /etc/exports the following can be done:
# exportfs -a
-a exports all the files and directories from /etc/exportfs to nfs clients. For unexport all exported files and directories the following are done:
# exportfs -ua
-u For Unexports all the files and directories from /etc/exportfs to nfs clients.