# NFS Sharing of /



## daBee (Apr 21, 2017)

Hi folks.

NFS up and running, but the `/etc/exports` file has me stumped.  I want to share the whole `/` so I inserted this directive:


```
# /etc/exports
/ -alldirs hq.local
/home   -alldirs        192.168.1.4
/home/rich/     -network 192.168.1.4
```
The last 2 directives were added later to see if I could get it to share properly.  I'd like to have my text editor have access (read + write) to my files.  Currently with the top directive, `/` is indeed shared, but `home` directory is giving me permissions issues. 

Anybody know what I'm doing wrong here?  BTW the `hosts` file has proper resolution to `hq.local`.  Any help appreciated. 

Cheers


----------



## Oko (Apr 21, 2017)

You have not posted enough details for us to troubleshoot your problem but for starters sharing any directory owned by root requires exporting things in so called "unsafe" mode. That should never be done in practice. Before we go any further you have to tell us if you are using NFSv3 or NFSv4 as they differ in configuration (personally I can't stand NFSv4 championed by Linux people and adopted only by FreeBSD of all BSDs). Secondly ZFS  is NFS aware. Great. There are two different ways to export ZFS data sets. One is "old fashion" way which you are doing. Another is via ZFS tunables. How do you syncronize accounts? Are you using NIS or LDAP server? This is just a server side info that you have to provide us with.

On the client side you have to tell us what OS (Linux distro) are running client machines? OS X had some ugly NFS client bugs but that should have being fixed 5-6 years ago.


----------



## daBee (Apr 21, 2017)

I'm on a LAN for one person.  I am using ZFS.  I don't synchronize accounts as there is one.  My client is OSX.  Nothing unsafe about exporting root in this case, because there is nobody else here.  I also tried exporting my home directory, but that isn't showing up either.  I've not read about old fashioned or new fashioned.  I'm trying to export as much as I can so I can stay out of pico and just run to my local editor over filesharing.  If there is an option for clearer config, then I'd take it.  

I wanted to export root because of the files in `/etc/`, but also my own scripts in `/home/rich/`.  I believe I am using NFS4.


----------



## ANOKNUSA (Apr 21, 2017)

Oko is right, in that you need to provide information on the complete configuration: the exports file, the contents of rc.conf on each system, the output of `showmount -e <server>`, how you try to mount the export, and what error message you get when trying to mount it.

I think you might be using NFSv3 (which is definitely the simpler and more manageable of the two). I believe the FreeBSD NFS daemons automatically choose the protocol based on the syntax used in your configuration files. Based only on what we know so far, the first thing I would try is to map your / export to the DHCP IP address assigned to the client. (I don't actually know what "hq.local" means, and my search hasn't turned up anything telling.) You should also remove the first of those two lines referring to /home, as it might conflict with the second; and since /home is a symlink, give the absolute path in the second export: /usr/home/rich.


----------



## daBee (Apr 25, 2017)

OK, sorry for the delay.  Here is that info.  It's simple as there's only the FreeBSD server and my OSX workstation where I want to mount this volume.  


```
[Tue Apr 25 04:27:32 rich@neb ~] showmount -e server
RPC: Unknown host
showmount: can't do exports rpc
```

Pertinent `/etc/rc.conf`


```
nfs_server_enable=YES
mountd_enable=YES
```


```
[Tue Apr 25 04:35:33 rich@neb ~] rpcinfo -p localhost
   program vers proto   port  service
    100000    4   tcp    111  rpcbind
    100000    3   tcp    111  rpcbind
    100000    2   tcp    111  rpcbind
    100000    4   udp    111  rpcbind
    100000    3   udp    111  rpcbind
    100000    2   udp    111  rpcbind
    100000    4 local    111  rpcbind
    100000    3 local    111  rpcbind
    100000    2 local    111  rpcbind
    100005    1   udp    813  mountd
    100005    3   udp    813  mountd
    100005    1   tcp    813  mountd
    100005    3   tcp    813  mountd
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
```


```
# RF mods in /etc/exports
#/ -alldirs hq.local
/usr/home/rich/         -network        192.168.1.4
```


----------



## SirDice (Apr 25, 2017)

daBee said:


> ```
> [Tue Apr 25 04:27:32 rich@neb ~] showmount -e server
> RPC: Unknown host
> showmount: can't do exports rpc
> ```


You're supposed to replace <server> with the name or IP address of the server.



```
dice@maelcum:~ % showmount -e molly
Exports list on molly:
/usr/src                           192.168.10.0 
/storage/media                     192.168.10.0
/usr/obj                           192.168.10.0
```


----------



## daBee (Apr 25, 2017)

Sorry, it's late/early.  


```
[Tue Apr 25 05:05:06 rich@neb ~/RF_scripts] showmount -e localhost
Exports list on localhost:
/usr/home/rich/                    192.168.1.4
```


----------



## SirDice (Apr 25, 2017)

Ok, that shows that /usr/home/rich/ is allowed to share to a client with IP 192.168.1.4.


----------



## daBee (Apr 25, 2017)

I'm rebooting to see what shows up.  OK I can't mount anything.  


```
Port Scanning host: 192.168.1.23

    Open TCP Port:     22             ssh
    Open TCP Port:     111            sunrpc
    Open TCP Port:     908
```


----------



## SirDice (Apr 25, 2017)

What are the errors?


----------



## daBee (Apr 25, 2017)

```
"There was a problem connecting to the server 'neb.local'.  You do not have permissions to access this server."
```
  Used a link nfs://username:password@neb.local/home/rich/


----------



## SirDice (Apr 25, 2017)

NFS doesn't use usernames/passwords.


----------



## daBee (Apr 25, 2017)

Tried `nfs://192.168.1.23` and `nfs://192.168.1.23/home/rich`, both nothing.  


```
Port Scanning host: 192.168.1.23
    Open TCP Port:     22             ssh
    Open TCP Port:     111            sunrpc
    Open TCP Port:     908
    Open TCP Port:     2049           nfsd
Port Scan has completed…
```


----------



## SirDice (Apr 25, 2017)

Only a client with IP address 192.168.1.4 is allowed to mount it.


----------



## daBee (Apr 25, 2017)

Yep, that's what I'm sitting on.  Is there an NFS log somewhere?

Update:  Found it.  


```
Apr 25 05:07:39 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 05:07:39 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 05:07:55 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 05:07:55 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 05:08:21 neb kernel: Limiting closed port RST response from 207 to 200 packets/sec
Apr 25 05:08:24 neb last message repeated 3 times
Apr 25 05:13:28 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 05:13:52 neb last message repeated 3 times
Apr 25 05:16:06 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 05:16:28 neb last message repeated 3 times
Apr 25 08:45:56 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 08:45:56 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 08:46:12 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 08:46:12 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 08:47:41 neb kernel: Limiting closed port RST response from 207 to 200 packets/sec
Apr 25 08:47:59 neb last message repeated 15 times
Apr 25 08:51:36 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 08:51:36 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 08:51:43 neb mountd[563]: mount request denied from 192.168.1.4 for /usr
Apr 25 08:51:43 neb mountd[563]: mount request denied from 192.168.1.4 for /usr
Apr 25 08:51:47 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home
Apr 25 08:51:47 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home
Apr 25 08:51:51 neb mountd[563]: mount request denied from 192.168.1.4 for /usr/home/rich
Apr 25 08:51:53 neb last message repeated 3 times
Apr 25 08:52:31 neb mountd[563]: mount request denied from 192.168.1.4 for /
Apr 25 08:52:31 neb mountd[563]: mount request denied from 192.168.1.4 for /
```


----------



## SirDice (Apr 25, 2017)

Try adding this flag to mountd(8):

```
-n      Allow non-root mount requests to be served.  This should only be
             specified if there are clients such as PC's, that require it.  It
             will automatically clear the vfs.nfsrv.nfs_privport sysctl flag,
             which controls if the kernel will accept NFS requests from
             reserved ports only.
```


----------



## daBee (Apr 25, 2017)

Where would I put that?  The only time I'm calling mountd is in `rc.conf` and only to turn it on.


----------



## Phishfry (Apr 25, 2017)

Add to your /etc/rc.conf

```
mountd_flags="-n"
```


----------



## Phishfry (Apr 26, 2017)

From the manual you are missing lines on your NFS server
/etc/rc.conf

```
rpcbind_enable="YES"
nfs_server_enable=YES
mountd_enable=YES
mountd_flags="-n"
```
https://www.freebsd.org/doc/handbook/network-nfs.html

NFS Client /etc/rc.conf

```
nfs_client_enable="YES"
nfs_client_flags="-n 4"
```


----------



## daBee (Apr 26, 2017)

OK, i'm confused.  I have a server and a client.  The FreeBSD is the server.  My OSX workstation is the client.  Correct?

Two of those directives above in the first code were there.  Another attempt in the morning.  I appreciate all this.


----------



## daBee (Apr 28, 2017)

Well I got a bit further, but I still cannot save files over the LAN.  Continuing with NFS, I implemented Bonjour as per this page:

http://www.xbsd.nl/2010/09/apple-afp-filesharing-on-freebsd.html

I might go back to Samba to see if I can get this to work.  It's a low priority.


----------

