Date: Tue, 24 Feb 2015 10:37:42 -0500 From: Kurt Lidl <lidl@pix.net> To: freebsd-fs@freebsd.org Subject: Re: The magic of ZFS and NFS (2nd try) Message-ID: <54EC9AC6.5000109@pix.net> In-Reply-To: <12103095.viZFqgegqA@falbala.rz1.convenimus.net> References: <12103095.viZFqgegqA@falbala.rz1.convenimus.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> Rainer Duffner wrote: > >> You must use the syntax of exports(5) also with zfs set sharenfs= >> AFAIK, you shouldn’t use /etc/exports to do zfs exports but the above >> command > > But why shouldn't I use /etc/exports? I have read people writing this (don't > use /etc/exports) in forums when searching for answers, however the current > manpage for zfs says this: > > 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. > > To me this looks like I can choose whether I want to use the exports file > or if I wish to set the sharenfs flag. I don't really *that* much, although > I don't really think this is something that a file system should decide, but > should be set from the NFS server. Well, I would argue (putting aside Jordan's semi-rant), that the correct thing to do is use the sharenfs flag for ZFS filesystems, as already recommended. The mechanics of using it are straightforward: zfs set sharenfs="things you would put in /etc/exports" path/to/zfs In a more concrete example, on one of my machines, I have: root@hostname-134: zfs get all |grep sharenfs|grep zroot/fbsd zroot/fbsd sharenfs off default zroot/fbsd/10.0-amd64 sharenfs -maproot=root local zroot/fbsd/9.1-amd64 sharenfs -maproot=root -alldirs local zroot/fbsd/9.1-sparc64 sharenfs -maproot=root -alldirs local Those were created via: zfs set sharenfs="-maproot=root" zroot/fbsd/10.0-amd64 After doing that, the file /etc/zfs/exports was automatically created for me (look, no need to manually edit /etc/exports): root@hostname-135: cat /etc/zfs/exports # !!! DO NOT EDIT THIS FILE MANUALLY !!! /fbsd/10.0-amd64 -maproot=root /fbsd/9.1-amd64 -maproot=root -alldirs /fbsd/9.1-sparc64 -maproot=root -alldirs All I had to do after this was restart my mountd daemon: root@hostname-136: service mountd restart Stopping mountd. Starting mountd. root@hostname-137: ps -auxww | grep mountd root 58779 0.0 0.1 10232 2312 ?? Ss 10:30AM 0:00.01 /usr/sbin/mountd -r /etc/exports /etc/zfs/exports Make sure that you have the appropriate NFS daemons started in your server's /etc/rc.conf: # NFS server things # (inetd is needed for tftpd) inetd_enable="YES" mountd_enable="YES" mountd_flags="-r" nfs_server_enable="YES" nfs_server_flags="-u -t -n 4" rarpd_enable="YES" rpcbind_enable="YES" rpc_lockd_enable="YES" rpc_statd_enable="YES" I enable inetd because I need to have tftpd running for diskless booting of my sparcs when I play with them, along with some other, older machines. The examples above work fine for me on FreeBSD 9.1, and I've done the same thing on FreeBSD 10.1 too - this has worked fine for pretty long time. -Kurt
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54EC9AC6.5000109>