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
/etc/zfs/exports:
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
> NAME PROPERTY VALUE
> SOURCE
> tank/export1 sharenfs -maproot=root -alldir -network 10.0.0.3 -mask
> 255.255.255.255 local
> (root at zega) /etc/zfs#
>
> (root at zega) /etc/zfs# cat /etc/zfs/exports
>
> # !!! DO NOT EDIT THIS FILE MANUALLY !!!
>
>
> (root at zega) /etc/zfs#
>
> (root at zega) /etc/zfs# showmount -e
> Exports list on localhost:
> /export0 10.0.0.3
> (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 10.0.0.3 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 10.0.0.3 -mask
255.255.255.255" 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.
Scot
More information about the freebsd-current
mailing list