ZFS NFS share options

Phobios

Member

Reaction score: 2
Messages: 26

I am trying to use the zfs set sharenfs command in order to share a directory with specific options, but whenever I try to add more than the -ro flag (ie zfs set sharenfs="-ro" library/Movies), the share stops being listed when I run showmount -e.

I tried adding just the async flag as well with zfs set sharenfs="-ro,-async" library/Movies, but as I said it stopped working. I am looking to get the following config for that particular directory:
Code:
"/library/Movies" -async,no_subtree_check,fsid=104 *(sec=sys,rw,insecure,anongid=100,anonuid=99,all_squash)

Can anyone help me out?
 

T-Daemon

Daemon

Reaction score: 878
Messages: 1,753

man zfs(8) states:
Rich (BB code):
sharenfs=on | off | opts
     Controls whether the file system is shared via    NFS, and what options
     are used. A file system with a    sharenfs property of off is managed
     the traditional way via exports(5).  Otherwise, the file system is
     automatically shared and unshared with    the "zfs share"    and "zfs
     unshare" commands. If the property is set to on no NFS    export options
     are used. Otherwise, NFS export options are equivalent    to the con-
     tents of this property. The export options may    be comma-separated.
     See exports(5)    for a list of valid options.

Example with valid options (from zfs(8)):

Code:
Example 16 Setting "sharenfs" Property Options on a ZFS File System

The following command shows how to set sharenfs property    options    to en-
       able root access    for a specific network on the tank/home    file system.
       The contents of the sharenfs property are valid exports(5) options.

     # zfs set sharenfs="maproot=root,network 192.168.0.0/24" tank/home

       Another way to write this command with the same result is:

     # set zfs sharenfs="-maproot=root -network 192.168.0.0/24" tank/home
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,319
Messages: 38,835

I've played around with the option in the past. While it works fine for fairly simple sharing options it seems to be rather difficult to get more advanced sharing options in there. In the end I found it easier just to use plain old /etc/exports for this.

The option stems from Solaris where the sharenfs talks directly to the kernel to set the NFS shares. On FreeBSD it's more or less a hack that runs a script which creates a /etc/zfs/exports which in turn is used by nfsd(8).
 
OP
P

Phobios

Member

Reaction score: 2
Messages: 26

I recall going with the zfs way of sharing because I couldn't get the regular way working. Trying now to share via the regular way by first turning it off for zfs with zfs set sharenfs=off library/Movies and then trying to get it into /etc/exports with a simple /library/Movies -ro 192.168.0.0/16 and running service reload mountd. My mount still won't show up running the showmount command. Not sure what I am doing wrong.
 
OP
P

Phobios

Member

Reaction score: 2
Messages: 26

Thank you @T_Daemon, looks like I missed the initial dash in the network option. That works well, but I can't seem to add other options, like async or no_subtree_check without getting a bad exports list line in /var/log/messages
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,319
Messages: 38,835

That works well, but I can't seem to add other options, like async or no_subtree_check without getting a bad exports list line in /var/log/messages
Maybe read exports(5) from FreeBSD instead of trying Linux's exports options?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,319
Messages: 38,835

They're definitely not interchangeable. Each NFS implementation uses it's own syntax. Some options are the same, some options have similar functionality but called differently. And some options simply don't exist at all.

While the NFS protocol itself is standardized, how you actually configure it is not.
 
Top