ZFS Named Shares
You can also create a named share, which provides more flexibility in setting permissions and properties in an SMB environment. For example:
$ zfs share -o share.smb=on tank/workspace%myshare
In the preceding example, the zfs share
command creates an SMB share called myshare
of the tank/workspace
file system. You can access the SMB share and display or set specific permissions or ACLs through the .zfs/shares
directory of the file system. Each SMB share is represented by a separate .zfs/shares
file. For example:
$ ls -lv /tank/workspace/.zfs/shares
-rwxrwxrwx+ 1 root root 0 May 15 10:31 myshare
0:everyone@:read_data/write_data/append_data/read_xattr/write_xattr
/execute/delete_child/read_attributes/write_attributes/delete
/read_acl/write_acl/write_owner/synchronize:allow
Named shares inherit sharing properties from the parent file system. If you add the share.smb.guestok
property to the parent file system in the previous example, this property is inherited to the named share. For example:
$ zfs get -r share.smb.guestok tank/workspace
NAME PROPERTY VALUE SOURCE
tank/workspace share.smb.guestok on inherited from tank
tank/workspace%myshare share.smb.guestok on inherited from tank
Named shares can be helpful in the NFS environment when defining shares for a subdirectory of the file system. For example:
$ zfs create -o share.nfs=on -o share.nfs.anon=99 -o share.auto=off tank/home $ mkdir /tank/home/userA $ mkdir /tank/home/userB $ zfs share -o share.path=/tank/home/userA tank/home%userA $ zfs share -o share.path=/tank/home/userB tank/home%userB $ grep tank/home /etc/dfs/sharetab /tank/home/userA userA nfs anon=99,sec=sys,rw /tank/home/userB userB nfs anon=99,sec=sys,rw
The above example also illustrates that setting the share.auto
to off for a file system turns off the auto share for that file system while leaving all other property inheritance intact. Unlike most other sharing properties, the share.auto
property is not inheritable.
Named shares are also used when creating a public NFS share. A public share can only be created on a named NFS share. For example:
$ zfs create -o mountpoint=/pub tank/public $ zfs share -o share.nfs=on -o share.nfs.public=on tank/public%pubshare $ grep pub /etc/dfs/sharetab /pub pubshare nfs public,sec=sys,rw
See the
share_nfs
(8) and
share_smb
(8) man pages for a detailed description of NFS and SMB share properties.