ZFS sharenfs for volumes shared between FreeBSD and Linux

I am using a pool on both FreeBSD and Linux. Several filesystems are exported via NFS. So far I could not find a sharenfs line that would work for both operating systems. Instead, I am forced to use /etc/exports containing differing syntax like this:

For FreeBSD:
/z/SRC/FreeBSD/src/main -network 192.168.0.0/16
/z/SRC/FreeBSD/src/stable/15 -network 192.168.0.0/16

For Linux:
/z/SRC/FreeBSD/src/main 192.168.0.0/16(rw,root_squash,async) fec0:0:0:4d42::0/64(rw,root_squash,async)
/z/SRC/FreeBSD/src/stable/15 192.168.0.0/16(rw,root_squash,async) fec0:0:0:4d42::0/64(rw,root_squash,async)

The format described in the zfs man page seems to be for Solaris and is again different, although it also says that for FreeBSD, one could generate multiple definitions for a single pool by separating them with semicolons. This would allow me to also add the IPv6 network but is anyway incompatible with Linux.

It would be nice to have a common, mostly OS-agnostic format which gets translated to the needs of the specific OS automatically, with options not understood simply being ignored. Or maybe sharenfs_<OS> properties which override a pure sharenfs property, which might be more flexible but likely is uglier. I have even thought about using a user property and rewriting it dynamically into the sharenfs property by an OS-specific script during boot, but this would only work after a pool has been imported, and so the initial import would result in complaints from mountd whenever the other OS is booted.

If anybody is doing similar things, how are you dealing with this issue?

-- Martin
 
I think you're getting too agnostic. The OS specific exports work, right? Why fix it if it aint broken? ... or with respect, creating a solution in search of a problem.
 
Answering your "why...": There are two additional issues: When adding an exported filesystem, all OSes working with it must be booted to have their exports changed. And it may also happen that the pool is not imported at all, resulting in all exports entries being wrong.

-- Martin
 
Server side or client side? If server I can see maybe having to restart NFS server-side service
The server can boot Linux or FreeBSD, and /etc/exports must be changed on either system. After that, the mountd (FreeBSD) or nfs.service must be signaled. All of this is automatic when using the sharenfs property. One just creates a dataset with the appropriate sharenfs, and everything else happens "automagically". But this is not possible when dual-booting the server, as the export format is different for FreeBSD and Linux, and the text in the sharenfs property is copied more or less verbatim to the exports file. This is why a generic format would be helpful which would then be parsed into each OS's specific one.
 
Back
Top