# NFS troubles



## thedude22 (Nov 4, 2017)

I am trying to set up a media server on my local network to access from another machine running Kodi.  I have successfully created a ZFS pool mounted at /storage on my FreeBSD server.

I'm trying to export my ZFS pool via NFS to my Kodi box on the local network.  Here is my /etc/zfs/exports file on the server:

```
/storage    -alldirs -rootmap=root -network 192.168.1.*(ro,insecure,no_root_squash)
```
Kodi sees nothing under NFS. I tried mounting this on my laptop from the terminal (running Arch Linux still.  might switch eventually if drivers in FreeBSD are good to go)

I run on my laptop `sudo mount.nfs htpc:/storage /mnt -o vers=4`
and I get 

```
mount.nfs Protocol not supported
```
According to https://wiki.archlinux.org/index.php/NFS#Troubleshooting
this error occurs when you include the export root in the path of the NFS source.

Still not sure what I'm doing wrong.  Yes, /storage is the root folder, but I tried substituting /movies which is at /storage/movies and I get the same error.

I ran across a suggestion to check rpcinfo.
When I run `rpcinfo kodi` (kodi is my kodi box IP in /etc/hosts) on my laptop I get
rpcinfo: can't contact rpcbind: RPC: (unknown error code)

No idea what this means.

Here is the relevant part of my rc.conf file:

```
nfs_server_enable="YES"
mountd_enable="YES"
mountd_flags="YES"
weak_mountd_authentication="YES"
rpcbind_enable="YES"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
```
I tried resetting the services and it is looking for /etc/exports not /etc/zfs/exports.  I moved the file but my results have not changed.


Any help would be greatly appreciated.

Edit : It appears I'm not using nfsv4.  When I try `sudo mount.nfs htpc:/storage /mnt -o vers=3` I get

```
mount.nfs: access denied by server while mounting htpc:/storage
```


----------



## thedude22 (Nov 4, 2017)

NFS seems a p.i.t.a.  I set up FTP effortlessly.  I guess I'll just use that instead.


----------



## SirDice (Nov 6, 2017)

thedude22 said:


> I am trying to set up a media server on my local network to access from another machine running Kodi.  I have successfully created a ZFS pool mounted at /storage on my FreeBSD server.
> 
> I'm trying to export my ZFS pool via NFS to my Kodi box on the local network.  Here is my /etc/zfs/exports file on the server:
> 
> ...



Use /etc/exports, the /etc/zfs/exports file is dynamically generated if use `zfs sharenfs ...` (not recommended). It also contains Linux's export options instead of FreeBSD's exports(5) options.



thedude22 said:


> NFS seems a p.i.t.a. I set up FTP effortlessly. I guess I'll just use that instead.


It's a pain because you're trying Linux options and are using the wrong exports(5) file.


----------



## thedude22 (Nov 6, 2017)

I already tried using /etc/exports and I'm now using that file again, but it still refuses to mount on my laptop.  It says something like access denied by the server.  The only reason I was using /etc/zfs/exports is because /etc/exports wasn't working in the first place.  I managed to get NFS running on Linux before switching over but I remember it being a chore there also. 

What are the linux options you are referring to?  You mean the stuff in parentheses?  I think I tried originally without any options there and I still couldn't mount it.  I'll try again when I get home.  I do recall that kodi would not see the shares from my Linux server at all without the insecure option.  I don't even know what it does to be honest. 

The only reason I'm really considering it instead of ftp, which was trivial to set up, is because I have heard NFS is generally faster which may become relevant for high bitrate media, e.g. 4k video files.  At the moment I don't even have a 4k display so I'm not too worried about it. 

Thanks for your response.


----------



## SirDice (Nov 6, 2017)

After reloading NFS check /var/log/messages, if you make mistakes the reason why it's not working will be logged there. Also don't forget to reload nfsd(8) and mountd(8) after changing the /etc/exports. Then check if the export is successful: `showmount -e`.


----------



## thedude22 (Nov 6, 2017)

Ok now we're getting somewhere.

One option should be -maproot not -rootmap.  I'm not sure where I got that from.
It also doesn't like using the asterisk to export to the whole subnet.

I didn't know about showmount or messages.  Thanks for the tips.
Yes I made a very big mess of my exports file.  I really should spend more time reading the man pages and the documentation.  I know I shouldn't just go running to the forums with every problem I run across but I just feel like I never have enough time.

I can now mount the NFS share on my laptop.  However kodi still cannot see the shares.  I know on Linux you have to export with the 'insecure' option which means:

secure This   option   requires   that  requests  originate  on  an  Internet  port  less  than
              IPPORT_RESERVED (1024). This option is on by default. To turn it off, specify insecure.

Is there a freebsd option similar to this?  The only mention of ports in the man page is using the webnfs or public tags.  I tried the public tag but still nothing.

By the way I tried following the official kodi help at http://kodi.wiki/view/NFS#NFS_sharing_from_FreeBSD

I think there are some mistakes here though.  For example they say to use -network=192....   when it seems it should be -network 192....

Here is my updated exports file:

/storage    -alldirs -maproot=root  -network 192.168.1.6/24

I can mount in Linux, but kodi does not see it still.  I guess it's a question for the kodi forums at this point.


----------



## SirDice (Nov 7, 2017)

thedude22 said:


> I can now mount the NFS share on my laptop. However kodi still cannot see the shares.


There's nothing in the NFS protocol that allows you to "browse" exported filesystems, a lot of Linux distributions (and Kodi) actually use Avahi for this. Just enter the path by hand on Kodi.


----------



## thedude22 (Nov 8, 2017)

I don't really understand what you mean.  Previously with my Linux server hosting the files I could select NFS as a source in kodi (from the other machine) and the filesystem would just show up.  I guess it mounted itself.  From there I could browse the files inside.  But for now ftp is working fine for me.  ~25GB blu rays are streaming fine without dropping or buffering.  I'll revisit this in the future if the higher capacity UHD disks prove to be too much for the protocol.

I'm really enjoying the FreeBSD OS though.  It's been fun learning it.  I think there's a lot to like here.  I especially like how organized everything is.  As a media server it's very solid.  I don't think I'm ready to dive in on my laptop quite yet.  I still enjoy playing around with unity3d on linux.   If it ever gets ported I'll make the leap there too.


----------



## SirDice (Nov 8, 2017)

thedude22 said:


> Previously with my Linux server hosting the files I could select NFS as a source in kodi (from the other machine) and the filesystem would just show up.


That's Avihi/Bonjour (zeroconf) that does this, not NFS itself.

https://en.wikipedia.org/wiki/Avahi_(software)


----------

