exportfs Command
Purpose
Exports and unexports directories to NFS clients.
Syntax
/usr/sbin/exportfs [ -a ] [ -v ] [ -u ] [ -i ] [ -fFile ] [ -F ] [ -oOption [ ,Option ... ] ] [ -V Exported Version] [ Directory ]
Description
The exportfs command makes local directories available for Network File System (NFS) clients to mount. This command is normally invoked during system startup by the /etc/rc.nfsfile and uses information in the /etc/exports file to export one or more directories, which must be specified with full path names.
The /etc/xtab file lists directories that are currently exported. To display this file, enter the exportfs command without flags or arguments. To alter the file or to alter the characteristics of one of its directories, root users can edit the /etc/exports file and run the exportfs command. Such alterations can be done at any time. Never edit the /etc/xtab file directly.
- You cannot export a directory that is either a parent directory or a subdirectory of one that is currently exported and within the same file system.
- NFS versions 2 and 3 allow both directories and files to be exported. Only directories can be exported for NFS version 4 access.
- If two entries for the same directory with different versions 2 (or 3) and 4 exist in the /etc/exports file, the exportfs command exports both of the entries.
- If the options for NFS versions 2 (or 3) and 4 are the same for a directory, there can be one entry in the /etc/exports file specifying -vers=3:4.
Flags
Item | Description |
---|---|
-a | Exports all directories listed in the exports file. |
-v | Prints the name of each directory as it is exported or unexported. |
-u | Unexports the directories you specify. When used with the -a flag, unexports all exported directories. When used with both the -a and -f flags, unexports all directories in the specified export file. |
-i | Allows the exporting of directories not specified in the exports file or ignores the options in the exports file. Unless the -f flag is used to specify an alternate file, the exportfs command will normally consult the /etc/exports file for the options associated with the exported directory." |
-f File | Specifies an export file, instead of the /etc/exports file, that contains a list of directories that you can export. This file should follow the same format as the /etc/exports file. NOTE: This alternate file will not be used for exporting directories automatically when the system and NFS is started. The /etc/exports file is the only file that is supported for specifying directories to export at system start. |
-F | Specifies that a forced unexport should be performed. Use this flag only with the -u flag. This flag has no effect when unexporting a V2/V3 export. A V4 unexport can fail due to associated state. This flag forces the release of any state associated with a V4 export. |
-oOptions | Specifies the optional characteristics for the directory being
exported. You can enter more than one variable by separating them
with commas. For options taking a Client parameter, Client can
specify a hostname, a dotted IP address, a network name, or a subnet
designator. A subnet designator is of the form "@host/mask",
where host is either a hostname or a dotted IP address and mask specifies
the number of bits to use when checking access. If mask is
not specified, a full mask is used. For example, the designator @client.group.company.com/16 will
match all Clients on the company.com subnet. A designator
of @client.group.company.com/24 will match only the
Clients on the group.company.com subnet. Choose
from the following options:
|
-o Options (continued) |
|
-o Options (continued) |
|
-o Options (continued) |
|
-o Options (continued) |
Whenever the attributes of a Client change, all export entries that contain that Client as a parameter should be exported again. Events that can change a Client's attributes include modifying a netgroup or changing the IP address of a client. Failure to do so can result in the server using old client information. |
-V Exported Version | Specifies the version number. Valid version numbers are 2, 3 and 4. |
Solaris Compatibility
The exportfs command may be invoked as share, shareall, unshare, or unshareall. When the exportfs command is invoked as share or shareall, the functionality is equivalent to exportfs and exportfs -a, respectively, except that the sec option must be used to specify the security methods. When the exportfs command is invoked as unshare or unshareall, the functionality is equivalent to exportfs -u and exportfs -u -a, respectively.
Security
Examples
- To export all directories in the /etc/exports file, enter:
exportfs -a
- To export one directory from the /etc/exports file, enter:
exportfs /home/notes
In this example, the /home/notes directory is exported.Note: For this command to work, the /home/notes directory must be specified in the /etc/exports file. - To unexport a directory, enter:
exportfs -u /home/notes
In this example, the /home/notes directory is unexported.
- To display the name of the directory currently being exported,
enter:
exportfs -v
- To export a directory that is not specified in the /etc/exports file,
enter:
exportfs -i /home/zeus
In this example, the /home/zeus directory is exported without restrictions.
- To export a directory and give netgroup members permission to
access this directory, enter:
exportfs access=cowboys:oilers /home/notes -o
In this example, the /home/notes directory is exported and permits users of cowboys and oilers host machines to have access.
- To export a directory with different options from the /etc/exports file,
enter:
exportfs -i -o root=zorro:silver /directory
In this example, the /directory directory is exported and allows root user access to zorro and silver host machines, regardless of the access permissions specified in the /etc/exports file.
- To export the /common/docs directory with write permissions
to clients using Kerberos authentication, but read-only permissions
to clients using UNIX authentication,
add the following text to the /etc/exports file:
/common/docs -sec=krb5,rw,sec=sys,ro
Then enter
exportfs /common/docs
to perform the export. - To create a referral at /usr/info to
the /usr/info directory on host
infoserver
, add the following line to /etc/exports and then export /usr/info:/usr/info -vers=4,refer=/usr/info@infoserver
- To specify replicas for the /common/info directory
at hosts
backup1
andbackup2
, add the following line to /etc/exports and then export /common/info:/common/info -vers=4,replicas=/common/info@backup1:/common/info@backup2,<other options>
- To export the /common/docs directory with both version
3 and version 4, enter the following command:
exportfs -V 3:4 /common/docs
- To export all of the version 4 entries in the /etc/exports file,
enter the following command:
exportfs -a -V 4
- To unexport the /common/docs directory only for version
3, enter the following command:
exportfs -u -V 3 /common/docs
- To unexport all of the version 3 entries in the /etc/xtab file,
enter the following command:
exportfs -ua -V 3
- To specify referrals for the /common/docs directory at
hosts named s1, s2, and s3 and scatter them fully, add
the following line to the /etc/exports file and then export
the /common/docs directory:
/common/docs -vers=4,refer=/common/docs@s1:/common/docs@s2:/common/docs@s3,scatter=full
- To specify replicas for the /common/docs directory at hosts
named s1, s2, s3, and s4 and scatter them partially
(the first fail over server is s1 for all combinations),
add the following line to the /etc/exports file and then export
the /common/docs directory:
/common/docs -vers=4,noauto,replicas=/common/docs@s1:/common/docs@s2:/common/docs@s3:/common/docs@s4,scatter=partial
Files
Item | Description |
---|---|
/etc/exports | Lists the directories that the server can export. |
/etc/xtab | Lists currently exported directories. |
/etc/hosts | Contains an entry for each host on the network. |
/etc/netgroup | Contains information about each user group on the network. |
/etc/rc.nfs | Contains the startup script for the NFS and NIS daemons. |