# help with NFS



## VampirD (Feb 13, 2013)

Hi, I have a NFS server on FreeBSD 9.0 where:

/etc/exports

```
/srv/vampird             -mapall=vampird katniss
/data           -alldirs -mapall=vampird katniss
```

and /etc/rc.conf

```
# NFS server config
nfs_reserved_port_only="YES"
nfs_server_enable="YES"
```

inside /data, I have a directory called compressed, create by the command:

```
zfs set compression=gzip data/compressed
```

On the katniss host I can mount /srv/vampird without problems, but when I mount /data the directory compressed is mapped to root instead of vampird. Any help????


----------



## Sebulon (Feb 13, 2013)

@VampirD

Please show the output of:
`# ls -lah /data`

/Sebulon


----------



## VampirD (Feb 13, 2013)

```
total 9
drwxr-xr-x   4 vampird  vampires     4B Feb 13 02:04 .
drwxr-xr-x  20 root     wheel      1.0k Feb  9 12:13 ..
drwx------   4 vampird  vampires     4B Feb 13 01:52 .Trash-1000
drwxr-xr-x   2 vampird  vampires     3B Feb 12 11:35 compressed
```


----------



## Sebulon (Feb 13, 2013)

OK, how does it look like if you mount it and show from a client:
`# mount server.foo.bar:/data /mnt`
`# ls -lah /mnt`
?

/Sebulon


----------



## VampirD (Feb 13, 2013)

katniss is a linux pc


```
katniss:~ # mount devilette:/data /mnt/data
katniss:~ # ls -lah /mnt/data
total 8.5K
drwxr-xr-x 4 vampird 1001    4 Feb 13 02:04 .
drwxr-xr-x 5 root    root 4.0K Feb  9 12:32 ..
drwx------ 4 vampird 1001    4 Feb 13 01:52 .Trash-1000
drwxr-xr-x 2 root    root    2 Feb  9 12:14 compressed
katniss:~ #
```


----------



## usdmatt (Feb 13, 2013)

/data/compressed is a separate file system so I believe you may have to mount that separately. The -alldirs option allows you to mount at any point under the original share but I'm not sure if that works if the directory is actually another file system. You might have to explicitly export /data/compressed on the server.


```
# mount server.foo.bar:/data/compressed /mnt/data/compressed
```

I think you're seeing the effects of that common confusing brain teaser of being able to see the compressed folder on the /data file system on the client, which has a completely different file system mounted over the top of it on the server. I could be completely wrong but it's the only explanation I can come up with considering you're clearly seeing different owner/group information on the same folder.


----------



## VampirD (Feb 13, 2013)

Solved, I read a bit more and use:

```
zfs set sharenfs="-alldirs -mapall=vampird katniss" data/compressed
```


----------



## usdmatt (Feb 13, 2013)

Didn't even cross my mind about the zfs sharenfs options.

If you run that sharenfs command against the root dataset (data), it should be automatically inherited by data/compressed, and both file systems (/data & /data/compressed) will be automatically added to /etc/zfs/exports. It'll even reload the NFS mount daemon for you. You should be able to clear out /etc/exports and just leave the /srv/vampird entry in there.

If you add any other file systems under /data in the future they will inherit the sharenfs property (unless you set it manually) and they'll be shared automatically as well.

Edit: Actually it probably won't be inherited automatically by /data/compressed as you've manually set it. You'd need to run the following:


```
# zfs set sharenfs="-alldirs -mapall=vampird katniss" data
# zfs inherit sharenfs data/compressed
```


----------



## Sebulon (Feb 13, 2013)

@VampirD

I agree with matt here that it is an effect of compressed actually being a separate filesystem.



			
				usdmatt said:
			
		

> # zfs set sharenfs="-alldirs -mapall=vampird katniss" data
> # zfs inherit sharenfs data/compressed



This has the same effect as having:
/etc/exports:

```
/srv/vampird             -mapall=vampird katniss
/data                    -mapall=vampird katniss
/data/compressed         -mapall=vampird katniss
```

ItÂ´s just that IÂ´ve always been too oldschool to dare use the sharenfs property

@usdmatt

It would be interesting to set up a similar environment but with plain UFS instead, just to rule out the ZFS involvement in this.

/Sebulon


----------



## VampirD (Feb 14, 2013)

thanks to both of you, and writting it to my wiki


----------

