The OSX way of setting up NFS Shares for pools and subvols?

All your general support questions for OpenZFS on OS X.

The OSX way of setting up NFS Shares for pools and subvols?

Postby ylluminate » Thu May 24, 2018 8:45 am

What's the "proper" way to set up an NFS share on macOS with ZFS?

For example, the current recommended method for setting it up via Oracle is:
Code: Select all
$ zfs set share=name=fs1,path=/fs1,prot=nfs mypool/fs1
$ zfs set sharenfs=on mypool/fs1

In my case I'd like to share an entire pool, like this:
Code: Select all
$ zfs set share=name=tank,path=/Volumes/tank,prot=nfs tank

But when I do this, it returns an error:
cannot set property for 'tank': invalid property 'share'

I figure there's a mac way to do this I'm missing.

Further, if I simply do:
Code: Select all
$ zfs set sharenfs=on tank


I see that the shares are set up in /etc/exports and that subvolumes are shared, however when I go to mount the pool or subvols on another workstation, I get an error:
Code: Select all
$ mkdir ~/mountpoint
$ sudo mount -v -o intr,noatime -t nfs 192.168.1.45:/Volumes/tank /Users/username/mountpoint
    mount: realpath /Users/username/mountpoint: Input/output error
Last edited by ylluminate on Fri Jun 01, 2018 12:05 pm, edited 1 time in total.
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby tangles » Mon May 28, 2018 4:13 am

I use NAS4Free to create an extra copy of my data…
Looking at one example of zfs datasets of the pool Backity in /etc/exports:
Code: Select all
/Backity/Video -quiet -mapall=root -network 192.168.1.0 -mask 255.255.255.0
On macOS 10.13.4, all I have inside an Automator app is a do shell script of:
Code: Select all
mount_nfs 192.168.1.60:/Backity/Video /Users/Shared/NFS/Video

On my clients at the path /Users/Shared/NFS/ I have a folder for each line in the exports config file.
Instantly works and mounts on the desktop for me.

To get NFS server working on macOS High Sierra, I just googled now and found:
https://www.reddit.com/r/kodi/comments/ ... h=fd495376

You might want to take a look at Lingon to manage your plist files so that NFSd starts at start up too. I use Lingon to create my nightly/weekly snapshots and also to scrub monthly.


If you want to know what version of NFS you're using to connect to the server:
Code: Select all
nfsstat -m

If you're trying to mount a ZFS share in /Volumes/ you'll have to contend with file permissions all the time, plus macOS will delete the mount folder on you each time you eject/restart/shutdown too, so probably best to just mount anywhere other than /Volumes really…
I don't use NFS all that much anymore.
Cheers.
tangles
 
Posts: 131
Joined: Tue Jun 17, 2014 6:54 am

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby lundman » Tue May 29, 2018 6:38 pm

I believe I tried to copy the illumos syntax with sharenfs, so it would be something like:

zfs set sharenfs=rw=@192.168.12.0/24,root=@192.168.12.0/24 $pool/$dataset

well make ZFS edit /etc/exports for you.

Or you can leave sharenfs off, and manually edit /etc/exports as well, there is also the cmdline "sharing" tool, which ZFS uses.
User avatar
lundman
 
Posts: 486
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby ylluminate » Fri Jun 01, 2018 12:05 pm

@lundman, thanks for that. So the "zfs set share" precursory step is not necessary with your implementation, right? I guess when I look at Linux focused guides vs Oracle provided docs this lines up much better... (eg, https://www.hiroom2.com/2016/05/18/ubun ... a-nfs-smb/) The key takeaway here seems to be that `zfs share $pool/$dataset` is not needed on macOS ZFS.

So in theory, `sudo zfs set sharenfs=rw tank` should set up the export so that any user from anything that has access to the server / host should be able to mount it as long as the UIDs mate up, right? (I tried some other more advanced shares as well as this one, but no joy so far.)

So from the other macOS workstation that will be mounting this share, I simply did this and met with failure:
Code: Select all
$ cd ~; mkdir mount
$ mount -t nfs 192.168.0.5:/Volumes/tank mount   #also tried prepending sudo to this
mount_nfs: can't mount /Volumes/tank from 192.168.0.5 onto /Users/username/mount: Permission denied

After some more digging, I'm seeing that, it appears, I need to add `insecure` to the arguments. When I attempt to add args such as `insecure` or others, I get the following:
Code: Select all
$ sudo zfs set sharenfs=rw,insecure tank
cannot set property for 'tank': 'sharenfs' cannot be set to invalid options


Likewise more complex attempts yield the same:
Code: Select all
$ sudo zfs set sharenfs=rw=@192.168.0.0/24,root=@192.168.0.0/24,rw=@192.168.5.0/24,root=@192.168.5.0/24,insecure tank
cannot set property for 'tank': 'sharenfs' cannot be set to invalid options
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby ylluminate » Fri Jun 01, 2018 1:29 pm

So adding to the last, I was able to get it working at least somewhat.

First, I added `/sbin/nfsd -N -vvv` via Lingon X for `com.apple.nfsd` to sanitize things a little. Oddly editing the plist by itself for nfsd actually caused an error; it seems that it didn't like the quotes that are in by default when you add the string, so it was simpler just using an app like Lingon to be sure it's clean.

I then created a basic share to see what would happen:
Code: Select all
$ sudo zfs set sharenfs=rw=@192.168.5.0/24 tank

I then edited `/etc/exports` manually. I noticed that the pool `tank` itself was not present (apparently a glitch in the handling of creating the shares?), so I added it to the top of the file. I then added `-mapall=501` since that user is the primary owner of the pool and sub volumes.

There are a number of sub volumes and so the main pool and sub volumes are all in /etc/exports now.

I actually really would like to see the `zfs set sharenfs` working such that the pool + subs are all inserted. I'd also like to see us be able to add things like options in there such as `mapall` or `insecure` and such. Hopefully I'm just missing something there, but it sure makes it easier to edit things this way than via manually editing the exports file itself when there are updates to the volumes.

BTW, is there any way to mount a pool or dataset and recursively mount lower level datasets in one command? For example, right now if I want to mount a pool, pool/dataset1 and pool/dataset1/dataset2, I have to mount it via subsequent commands:
Code: Select all
$ sudo mount -t nfs 192.168.5.5:/Volumes/tank mount
$ sudo mount -t nfs 192.168.5.5:/Volumes/tank/dataset1 mount/dataset1
$ sudo mount -t nfs 192.168.5.5:/Volumes/tank/dataset1/dataset2 mount/dataset1/dataset2
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby tangles » Fri Jun 01, 2018 9:29 pm

This might be asking a tad too much.
remember that ZFS started out on Solaris and so features like setting NFS sharing could be done by sysadmins in their sleep.
With this in mind and that a lot of people havnt even heard of NFS, I think its fair to expect such aspects of sharing ZFS to a network be left to individuals.
I know I’d much prefer the devs to spend their free time on other core aspects of ZFS on macOS.

Think of it as a learning exercise perhaps…

:D
tangles
 
Posts: 131
Joined: Tue Jun 17, 2014 6:54 am

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby ylluminate » Sat Jun 02, 2018 6:23 am

tangles wrote:This might be asking a tad too much.
remember that ZFS started out on Solaris and so features like setting NFS sharing could be done by sysadmins in their sleep.
With this in mind and that a lot of people havnt even heard of NFS, I think its fair to expect such aspects of sharing ZFS to a network be left to individuals.
I know I’d much prefer the devs to spend their free time on other core aspects of ZFS on macOS.

Think of it as a learning exercise perhaps…

:D


Well, I guess I can get behind that if the feature's removed entirely from OpenZFS on OS X. I don't think leaving in a feature like this that kinda works is a good idea. It would be better that, when executed, it would say: Sorry, this feature needs additional work, please see <some link for discussion> and research <blah blah blah> to set this up properly on macOS. The unfortunate thing is that this command could be extremely useful in that it expands out to a high level of verbosity when executed vs having to create large config files with high specificity themselves, so it could be quite useful if just a little time were devoted to it, but I'm sure you're right about the lack thereof. Perhaps you or I could contribute to it sometime here and help flesh it out more fully.
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby lundman » Sun Jun 03, 2018 7:36 pm

ylluminate wrote:@lundman, thanks for that. So the "zfs set share" precursory step is not necessary with your implementation, right? I guess when I look at Linux focused guides vs Oracle provided docs


I believe "zfs set share" is an OracleZFS command, whereas OpenZFS uses "zfs set sharenfs" (sharesmb, shareafp).


After some more digging, I'm seeing that, it appears, I need to add `insecure` to the arguments. When I attempt to add args such as `insecure` or others, I get the following:


I'm surprised just sharing doesn't work. I have noticed I often have to add the IPs in /etc/hosts for NFS to work, but that could just be from "the good ol days". You can use
"showmount -e ip.ip.ip.ip" to see what is offered.

Looks like I maybe missed "insecure" as a valid option to nfs options, I can add that.
User avatar
lundman
 
Posts: 486
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: The OSX way of setting up NFS Shares for pools and subvo

Postby ylluminate » Sun Jun 03, 2018 10:08 pm

Thanks @lundman, oddly I've seen some mention of this `set share` on some Linux docs as well... I'm not entirely sure where this is coming in from yet. Perhaps I need to investigate a bit further.

Thanks, I guess we can keep testing the options here and see what may or may not be missing. This `insecure` option definitely isn't available, but I think some others are missing as well during my prancing about with this NFS escapade. The pool itself was definitely missing, which is strange because you should, it would seem, be able to just share a pool and the permissions will then propagate, as they do now - but the pool itself should be present in the exports list.
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm


Return to General Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron