ZFS sharenfs and NFS options

Scot Hetzel swhetzel at gmail.com
Wed Mar 5 09:27:22 PST 2008

On 3/5/08, Michael Jung <mikej at paymentallianceintl.com> wrote:
> When does /etc/zfs/exports get written?
It gets updated when you change the sharenfs property of a zfs filesystem.

>  Should you have to HUP mountd after adding the nfs share via "zfs set
>  sharenfs=....."? it doesn't make any difference for me.
>  Should showmount -e show the zfs exported NFS share?

showmount will show the zfs exported NFS share that is added to

hp010# zfs set sharenfs=on myzpool/test
hp010# showmount -e
Exports list on localhost:
/myzpool/test                      Everyone
hp010# zfs inherit sharenfs myzpool/test
hp010# showmount -e
Exports list on localhost:

>  (root at zega) /etc/zfs# zfs get sharenfs tank/export1
>  tank/export1  sharenfs  -maproot=root -alldir -network -mask
>  local
>  (root at zega) /etc/zfs#
>  (root at zega) /etc/zfs# cat /etc/zfs/exports
> (root at zega) /etc/zfs#
>  (root at zega) /etc/zfs# showmount -e
>  Exports list on localhost:
>  /export0                 
>  (root at zega) /etc/zfs#
>  (root at zega) /etc/zfs# uname -a
>  FreeBSD zega.mikej.com 7.0-STABLE FreeBSD 7.0-STABLE #2: Sun Mar  2
>  20:39:38 UTC 2008     mikej at zega.mikej.com:/usr/obj/usr/src/sys/ZEGA
>  i386
>  (root at zega) /etc/zfs#
>  NOTE****** /export0 is exported via /etc/exports
>  Needless to say, I'm not able to mount export1 on when I share
>  it via the "zfs set sharenfs" command.
>  exporting the ZFS mount point via /etc/exports works fine.
Make sure that zfs_enable="YES" is in rc.conf, restart
/etc/rc.d/mountd, then the mountd command will use both /etc/exports
and /etc/zfs/exports.

So to do nfs with ZFS, all you need to do is:

1. add zfs_enable="YES" to /etc/rc.conf
2. restart mountd (i.e. /etc/rc.d/mountd restart)
3. add your zfs shares:
  zfs sharenfs=on myzpool/test1
  zfs sharenfs="-maproot=root -alldir -network -mask" myzpool/test2

NOTE: sharenfs=on creates a nfs share that is available to everyone.

You should now be able to mount the zfs nfs filesystems on other
systems or locally.

mount -t nfs myserver:/myzpool/test1 /mnt

Unlike /etc/exports, zfs nfs shares are available immediately, no need
to restart mountd.


More information about the freebsd-current mailing list