Solaris 9 and later comes with an NFS server. To use it, edit the
/etc/dfs/dfstabfile. Place a share command in it using the syntax
share [-F FSType] [-o specific_options] [-d description] [pathname].
The following shows an entry made
to that file. Folders are shared via NFS using the
command. The options used are explained below:
|-F nfs||Specify the filesystem type for sharing to be NFS.|
|-o rw=PC1||Allow read and write access from one one client system named PC1|
# Place share(1M) commands here for automatic execution # on entering init state 3. # # Issue the command 'svcadm enable network/nfs/server' to # run the NFS daemon processes and the share commands, after adding # the very first entry to this file. # # share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource] # .e.g, # share -F nfs -o rw=engineering -d "home dirs" /export/home2 share -F nfs -o rw=PC1 -d "share" /export/home/jsmith/Documents/share
The options that can be specified with
-o are as follows:
-o specific_options The specific_options are used to control access of the shared resource. (See share_nfs(1M) for the NFS specific options.) They may be any of the following: rw pathname is shared read/write to all clients. This is also the default behavior. rw=client[:client]... pathname is shared read/write only to the listed clients. No other systems can access pathname. ro pathname is shared read-only to all clients.
Note: in the example above I used
as the directory to be shared. I had to use
under Solaris the
/home directory is a special directory.
For sharing something under it with NFS, you need to use
When I tried sharing the directory with the
command when I used
/home/jsmith/Documents/share, I received
an error message.
# shareall -F nfs share_nfs: /home/jim/Documents/share: Operation not applicable
Once I used
/etc/dfs/dfstab, I did not receive any error
messages when running
# shareall -F nfs #
dfstab file has been edited, start the
NFS server with
svcadm enable network/nfs/server.
You can check the state of the NFS server with the
$ svcs network/nfs/server STATE STIME FMRI disabled 14:19:50 svc:/network/nfs/server:default
You can use the
-v option with the
get more verbose information. You can use the
-r option to
enable other services on which it depends. Svcadm then enables each service
instance and recursively enables its dependencies.
-s option is specified, svcadm enables each service
instance and then waits for each service instance to enter the online or
degraded state. svcadm will return early if it determines that
the service cannot reach these states without administrator intervention.
# svcadm -v enable -r network/nfs/server svc:/network/nfs/server:default enabled. svc:/milestone/network enabled. svc:/network/loopback enabled. svc:/network/physical enabled. svc:/network/nfs/nlockmgr enabled. svc:/network/rpc/bind enabled. svc:/system/filesystem/minimal enabled. svc:/system/filesystem/usr enabled. svc:/system/boot-archive enabled. svc:/system/filesystem/root enabled. svc:/system/device/local enabled. svc:/system/identity:node enabled. svc:/system/sysidtool:net enabled. svc:/milestone/single-user:default enabled. svc:/milestone/devices enabled. svc:/system/device/fc-fabric enabled. svc:/system/sysevent enabled. svc:/system/manifest-import enabled. svc:/system/filesystem/local:default enabled. svc:/milestone/single-user enabled. svc:/system/filesystem/minimal:default enabled. svc:/system/identity:domain enabled. svc:/network/nfs/status enabled. svc:/system/filesystem/local enabled. # svcadm enable -s /network/nfs/server
If the service is still marked as disabled, you can use the
-d option, which lists the services or service
instances upon which the given service instances depend.
# svcs /network/nfs/server STATE STIME FMRI disabled 14:55:55 svc:/network/nfs/server:default # svcs -d /network/nfs/server STATE STIME FMRI disabled Jul_28 svc:/network/rpc/keyserv:default disabled Jul_28 svc:/network/nfs/mapid:default online Jul_28 svc:/milestone/network:default online Jul_28 svc:/system/filesystem/local:default online Jul_28 svc:/network/rpc/bind:default online Jul_28 svc:/network/nfs/nlockmgr:default online Jul_28 svc:/network/rpc/gss:default
When I tried starting the NFS server software on a Solaris 10
system, I didn't see error messages when I ran
svdadm enable -s
/network/nfs/server, but when I would check it afterwards with
svcs /network/nfs/server, the service was listed as disabled.
So I tried enabling the
services, which were listed as disabled.
# svcs keyserv STATE STIME FMRI disabled Jul_28 svc:/network/rpc/keyserv:default # svcadm enable keyserv # svcs keyserv STATE STIME FMRI maintenance 15:43:56 svc:/network/rpc/keyserv:default # svcadm enable mapid # svcs mapid STATE STIME FMRI online 15:44:58 svc:/network/nfs/mapid:default # svcs /network/nfs/server STATE STIME FMRI disabled 14:55:55 svc:/network/nfs/server:default # svcadm enable -s /network/nfs/server svcadm: Instance "svc:/network/nfs/server:default" has been disabled by another entity. # svcs -x svc:/network/nfs/server svc:/network/nfs/server:default (NFS server) State: disabled since Sun Apr 26 15:45:46 2009 Reason: Disabled by an administrator. See: http://sun.com/msg/SMF-8000-05 See: nfsd(1M) See: /var/svc/log/network-nfs-server:default.log Impact: This service is not running.
I finally realized that the NFS service won't start if there is no
valid directory share. I had used
/etc/dfs/dfstab instead of
/export/home/jsmith/Documents/share. Once I corrected that
problem, I was able to enable the
# svcs /network/nfs/server STATE STIME FMRI online 16:15:32 svc:/network/nfs/server:default # svcadm enable -s /network/nfs/server # svcs /network/nfs/server STATE STIME FMRI online 16:15:32 svc:/network/nfs/server:default
I had previously run
svcadm enable -r /network/nfs/server to
recursively enable any other services that the NFS service depended upon.
mapid services had been listed
as disabled after I ran that command, but I had subsequenty enabled them when I
incorrectly concluded that the fact that they were disabled was keeping
the NFS server service from running, I disabled them again.
# svcadm disable keyserv # svcadm disable mapid # svcadm restart /network/nfs/server # svcs /network/nfs/server STATE STIME FMRI online 16:41:38 svc:/network/nfs/server:default
I then checked to verify the system was listening on the default port for NFS, port 2049.
# netstat -an | grep 2049 *.2049 Idle *.2049 Idle *.2049 Idle *.2049 *.* 0 0 49152 0 LISTEN *.2049 *.* 0 0 49152 0 LISTEN *.2049 *.* 0 0 49152 0 LISTEN # netstat -a | grep nfs *.nfsd Idle *.nfsd Idle *.nfsd Idle
Sharing directories with NFS in Solaris 10
Solaris Administration Secrets and Security
Setting up an NFS Server on Solaris
Date: December 21, 2003
Network Administrator Tools
Solaris 10: enable NFS server
Date: May 20, 2005
Tech-Recipes - Your cookbook of tech tutorials
[osol-help] unable to bring up nfs server on solaris 10
Date: May 15, 2007
The opensolaris-help Archives
NFS: Operation not applicable
Date: August 12, 2006
svcadm fails to enable nfs/server
Date: August 12, 2008
SUN Solaris - The UNIX and Linux Forums