zfs sharenfs with multiple hosts/networks and options
jhell at DataIX.net
Thu Aug 26 19:06:16 UTC 2010
On 08/25/2010 03:47, Heinrich Rebehn wrote:
> Hi list,
> with traditional /etc/exports i can do
> /export/linux/root -ro xxx.xxx.xxx.0/24
> /export/linux/root -maproot=0 xxx.xxx.xxx.1
> How can i do this using zfs's sharenfs option?
> When i try
> zfs set sharenfs="-ro -network xxx.xxx.xxx.0/24,-maproot=0 xxx.xxx.xxx.1" data/linux/root
> /var/log/messages shows "network/host conflict" and "bad exports list line.
> The general problem seems to be that with each "zfs set sharenfs" command, the corresponding in /etc/zfs/exports gets overwritten.
> Is there a workaround for this besides ignoring sharenfs and using hand edited /etc/exports?
> Thanks for any help,
All the sharenfs property is actually doing and maybe not exactly in
this order is modifying /etc/zfs/exports with the interpreted contents
of the sharenfs property and using a syntax that the native mountd(8)
understands or at least tries to in a very simple way. After this is all
done, mountd(8) recieves a HUP signal to inform if to reread
/etc/exports & /etc/zfs/exports. So traditionally everything is
happening the way it always has been except for the fact your now using
the zfs(1M) Sun command with our own patch on top of that to make it
look like its doing what you see in *Solaris or at least the interpreted
Currently we do not have a/the share(1M) command implemented. My
suggestion would be to write a script either in Python or Perl or maybe
even in C to parse your own command line arguments and adjust
/etc/exports or /etc/zfs/exports accordingly depending on the type of
filesystem your arguments point to and then send signal HUP to
mountd(8). This will at least be a little more under your control
without having to modify sources and deal with conflicts later. I would
recommend that you disable using the sharenfs property at all if you
choose to go this route as you may start to find inconsistencies among
The reference code where this is all happening is:
Disable handling of the sharenfs property (ZFS_PROP_SHARENFS):
Personally I would love to see our version of the sharenfs version
translated into something that is local to FreeBSD only like the
org.freebsd:swap local property that we use to enable swap on zvol's. My
theorized version of this would look a little like the following.
zfs set \
Where options are separated by commas and shares to different hosts or
networks are separated by semicolons.
But if you don't want to go through all this then you could always
designate /etc/zfs/exports as a permanent share for users that are
allowed to write and administered by the sharenfs property. And use
/etc/exports as your extraneous read-only shares. Just a thought.
Anyway! enough said. Good luck on your mission.
More information about the freebsd-stable