# Strange behaviour of NFS



## bsus (Oct 10, 2011)

Hi,

I run a FreeBSD 8.2-Release server which is used as data storage.
I have a ZFS raidz1 pool which contains a home dataset (storage/home) in this dataset are the user datasets (storage/home/<user>). Since I now changed the zfs "tree" NFS causes trouble. The clients mount NFS normaly over fstab and I can look into /home.
But the clients don't show any data in the subdirs/subvolumes of /home.
So /home/<user> is empty.

The issue now is that I have no idea why it is how it is. There no unusual logs no strange output - the subdirs of /home are just empty.

The data is reachable without any issues over samba. NFS and Samba are managed external not over the ZFS settings.

Regards


----------



## usdmatt (Oct 10, 2011)

Sounds like you're running into the same NFS feature that gets most people. NFS only exports a single file system and does not cross mount points. If you only export the 'storage/home' file system and your user folders are separate ZFS datasets (read: file systems) then you will not see them, just the directories where these sub datasets are mounted on the host.

Samba, on the other hand, will cross multiple file systems so you see the contents of the sub datasets fine.

If you export your root dataset with the ZFS sharenfs property, it should be inherited by all the sub datasets, exporting them as well. eg


```
zfs set sharenfs="-network 1.2.3.4/24" storage/home
```

Obviously you will want to put your own options in there.
This should add exports for all your user datasets to /etc/zfs/exports. You can still add anything you want to export manually to /etc/exports.

You should then be able to mount the individual user directories on the clients. Of course it's a bit of a pain if you need to have access to lots of user directories on one client. You may end up scrapping the idea of a dataset for each user if this is the case. It's one of the annoying things about using ZFS with NFS. ZFS encourages lots of filesystems, but NFS can't access them unless they are mounted separately. I heard a rumour that NFSv4 may have the ability to do this, either now or as a planned feature, but I'm not sure.


----------



## bsus (Oct 11, 2011)

Thank you for the good explination 

I used on the server following commands:

```
/etc/rc.d/mountd restart
zfs sharenfs=on storage/home
zfs sharenfs="-rw -alldir -network 192.168.178.31" storage/home
cat /etc/zfs/exports
# DO NOT EDIT THIS FILE MANUELLY !
```

Somehow ZFS doesn't write the share into its exports file.
When I want to mount the share over clients I am getting

```
mount.nfs: portmap query failed: RPC: Program not registered
mount.nfs; requested NFS version or transport protocol is not supported
```


----------



## bsus (Oct 11, 2011)

I menaged it now myself.
The problem was that the zfs mountpoint was set to legacy and that nfs doesn't accept more then one options

Now ZFS handles NFS but the issue from the beginning is still the same...
I still can't change into the subvolumes or subdir of home.


----------



## SirDice (Oct 11, 2011)

bsus said:
			
		

> nfs doesn't accept more then one options


It does, just not in the way you tried it.


```
dice@molly:~>zfs get sharenfs tank/FreeBSD/ports
NAME                PROPERTY  VALUE                                    SOURCE
tank/FreeBSD/ports  sharenfs  ro,maproot=0,network=2001:888:1c5b::/64  local
```


```
root@molly:~#cat /etc/zfs/exports
# !!! DO NOT EDIT THIS FILE MANUALLY !!!

/usr/ports      -ro -maproot=0 -network=2001:888:1c5b::/64
```

However, it doesn't seem to like more than one network statement though. I haven't been able to restrict it on both IPv4 _and_ IPv6.



			
				bsus said:
			
		

> I still can't change into the subvolumes or subdir of home.


Each and everyone of them will need to be exported and mounted individually.


----------



## bsus (Oct 11, 2011)

> It does, just not in the way you tried it.


And how do I do this?
I am missing the direct command or syntax to add more options. You just show some listing outputs.



> Each and everyone of them will need to be exported and mounted individually.


Until NFSv4?


Which option is recommand to limit NFS to some IPs?
At the moment I have about 5 full IPs in /etc/exports


----------



## SirDice (Oct 11, 2011)

bsus said:
			
		

> And how do I do this?
> I am missing the direct command or syntax to add more options. You just show some listing outputs.


For crying out loud. Just use your brain every once in a while..

`# zfs set sharenfs="ro,maproot=0,network=2001:888:1c5b::/64" tank/FreeBSD/ports`


----------



## bsus (Oct 11, 2011)

> For crying out loud. Just use your brain every once in a while..


Bad day?

Thanks


----------

