SolarisNFSQuickConfiguration

How to quickly configure NFS under Solaris 10

Overview:

1. Basic commands:

Just the name of the following should be enough to give you a hint what they do:

share
unshare
shareall

2. Main NFS configuration file:

You can find the NFS configuration file here:

/etc/dfs/dfstab

Why on earth did they name it dfstab in the directory /etc/dfs instead of the simpler /etc/nfs/nfstab truly is beyond me...

Anyway, this is valid for both Solaris 10 and Solaris 8 (and probably versions in-between).

3. Display NFS service status

This section is for Solaris 10 only, of course:

root@galactus$ svcs | grep -i nfs
online         May_29   svc:/network/nfs/status:default
online         May_29   svc:/network/nfs/nlockmgr:default
online         May_29   svc:/network/nfs/client:default
online         May_29   svc:/network/nfs/rquota:default

The svcs displays the status of all running services on a Solaris 10 server. Piping its output into grep is necessary to focus on what we are interested in. Please note anyone can use svcs, not just root.

Under Solaris 8, simply do the following:

spiderman:/ > ps -fe | grep -i nfs | grep -v grep
  daemon   331     1  0   Aug 31 ?        0:00 /usr/lib/nfs/statd
    root   330     1  0   Aug 31 ?        0:00 /usr/lib/nfs/lockd
    root   677     1  0   Aug 31 ?        0:00 /usr/lib/nfs/mountd
    root   679     1  0   Aug 31 ?        0:24 /usr/lib/nfs/nfsd -a 16

The above should be correct and provide a working NFS server.

Again, this is for Solaris 10:

root@galactus$ svcs -l svc:/network/nfs/status
fmri         svc:/network/nfs/status:default
name         NFS status monitor
enabled      true
state        online
next_state   none
state_time   Tue May 29 18:05:51 2007
logfile      /var/svc/log/network-nfs-status:default.log
restarter    svc:/system/svc/restarter:default
contract_id  36
dependency   require_any/error svc:/milestone/network (online)
dependency   require_all/restart svc:/network/rpc/bind (online)
dependency   require_all/error svc:/system/filesystem/local (online)

Mounting an NFS share on a remote machine

1. The NFS share has already been declared:

Use the mount command, Luke! :-)

root@galactus$ mount -F nfs -r surfer:/home/dcc102x /mnt/nfs

Then, check everything went well with:

root@galactus$ df -h /mnt/nfs/
Filesystem             size   used  avail capacity  Mounted on
surfer:/home/dcc102x   148G   142G   3.8G    98%    /mnt/nfs

All right, but remember that the machine galactus should be declared in the /etc/dfs/dfstab of the NFS server surfer for this command to work.

2. The NFS share has NOT been declared already:

This is a short example of a much much longer configuration file:

/usr/sbin/share -F nfs  -o rw=maki.gilandre.net:sushi.gilandre.net:sashimi.gilandre.net,ro=tempura.gilandre.net:
udon.gilandre.net:soba.gilandre.net:chahan.gilandre.net -d "/home/media/MP3" /home/media/MP3

In the example above, a Solaris 10 machine on the gilandre.net network exports /home/media/MP3 read-write to the machines sushi and sashimi. It also exports the same directory read-only to tempura, udon, soba and chahan. Please note that this configuration should be all on the same line.

(Yes, I like japanese food, how did you ever guess?) :-)

Once the /etc/dfs/dfstab has been edited correctly, proceed to the next step:

Two possibilities, that are 100% equivalent :

exportfs -a

Or:

shareall

... If the configuration has been edited correctly, you should be able to login on your NFS client and do a mount as shown above.

If not, take a look at the /etc/dfs/dfstab and make sure you haven't made a mistake editing it.

You usually do this in /etc/fstab under Linux and /etc/vfs/vfstab under Solaris. I'll let you take a look at the man pages for your local UNIX to determine the correct file on your system.

See Also:

The following pages are in French. All my apologies to my English-speaking readers!