Using sharemgr to manage NFS file systems on OpenSolaris hosts


I’ve supported Solaris NFS servers for as long as I can remember. The typical drill I follow to get a server up and running is:

​1. Work with a developer / app support to determine how much space is needed.

​2. Provision space on the server.

​3. Enabled the NFS server processes.

​4. Edit the /etc/dfs/sharetab file to share out the file system I provisioned.

​5. Update clients with the new mount information.

With recent opensolaris builds, step 4 has changed slightly. The new way to add NFS shares is through the sharemgr utility, which allows you to create share groups (i.e., these are groupings of similar network shares) and shares, add and remove properties to these shares, and enable and disable shares. To create a new share group, the sharemgr utility can be run with the “create” option, the protocol (NFS or SMB) to associate with this share, and the name of the share:

$ sharemgr create -P nfs build

Once a share group is created, you can use the “list” subcommand to view the group’s properties:

$ sharemgr list -v
default enabled nfs zfs enabled build enabled nfs

To add one or more shares to a group, you can run the sharemgr utility with the “add-share” subcommand, the directory to share out, and an optional description to associate with the share:

$ sharemgr add-share -s /bits/provisioning -d "Build infrastructure"
build**

To view shares, you can run sharemgr with the “show” option:

$ sharemgr show -v

default zfs build /bits/provisioning “Build infrastructure”

Now assuming you don’t want the world to be able to access the share, you will most likely want to configure some type of security to limit who can access it. To limit the list of clients that can access shares in the build group to the 192.168.1.0/24 network, you can run sharemgr with the “set” option, the protocol, the properties to set, and the share group to attach these properties to:

$ sharemgr set -P nfs -p anon=0,ro=@192.168.1.0/24 build

To view the properties, the sharemgr utility can once again be run with the “show” subcommand:

$ sharemgr show -vp

default nfs=() zfs build nfs=(anon=“0,ro=@192.168.1.0/24”) /bits/provisioning “Build infrastructure”

While a bit more complex than using echo to send a string to /ec/dfs/dfstab, the real utility comes into play when you are configuring SMB shares. Once I get around to testing out the opensolaris CIFS server, I will add a follow up post detailing how to use sharemgr to share out CIFS shares.

This article was posted by Matty on 2009-05-05 09:55:00 -0400 EDT