# ZFS, NFS and quota



## astperl (Oct 26, 2011)

Dear all,

I tried to use ZFS and quota in FreeBSD 8.2 R. NFS server share mount on ZFS only, not on UFS. I did:


```
# zfs set sharenfs=maproot=root,alldirs,network=192.168.1.0,mask=255.255.255.0 tank/home
# zfs set userquota@1005=4G tank/home
# zfs userspace tank/home
TYPE        NAME   USED  QUOTA  
POSIX User  1005   780M     4G  
POSIX User  root  5.50K   none
```

/etc/inetd.conf:

```
rquotad/1	dgram rpc/udp wait root	/usr/libexec/rpc.rquotad rpc.rquotad
```


On client side:

```
$ quota
Disk quotas for user nick (uid 1005): none
```

I think /etc/fstab with userquota option is not an option for ZFS.  How can I make client knows about their quota usage? Did I miss something?

Best regards,
Aston P


----------



## SirDice (Oct 26, 2011)

Do you have 
	
	



```
options QUOTA
```
 in your kernel config?

Handbook: 19.15 File System Quotas


----------



## astperl (Oct 26, 2011)

Yes, I have.
In fact NFS client can check quota just fine against UFS,


----------



## phoenix (Oct 27, 2011)

ZFS quotas are a per-filesystem thing.  UFS quotas are a per-user thing.  The two implementations are not compatible.  NFS only knows about per-user quotas.

You can kind of achieve a per-user quota over NFS to ZFS if you create individual filesystems for each user.  But you won't be able to query or view the quotas over NFS.  But the output of "df" can be used to approximate it (since whatever space is left in the filesystem is what's left in the quota).


----------



## astperl (Oct 31, 2011)

Did you mean individual filesystem by using the 
	
	



```
zfs create -V 4g tank/home
```
 ? If yes, does it have difference performance with standard ZFS partition with this kind of volume?

Regarding NFS quota on ZFS partition, OpenSolaris have this implemented on their rquotad two years ago. See it here.


----------



## phoenix (Nov 1, 2011)

No.  That creates a ZFS Volume (aka zvol), which you can then use as if it were a regular disk (as in, format it with whatever filesystem you want).

Per-filesystem quotas are set on ZFS filesystems via the zfs command:
`# zfs set quota=4G tank/home`

See the zfs() page.


----------



## leonderooij (Mar 14, 2012)

Did anyone find a solution to getting rquota working yet? (I'm using RELENG_9_0)

uid-based quotas seem to work fine on nfs exported zfs:

server:

```
# zfs create zroot/nfs
# zfs set mountpoint=/nfs zroot/nfs
# echo "/nfs -network=192.168.2.0/24" >> /etc/exports
# service mountd onereload
# adduser nfsuser
# zfs set userquota@nfsuser=5M zroot/nfs
```

client:

```
# mount freebsd-dev:/nfs /nfs
# su - nfsuser
$ dd if=/dev/zero of=toomuch bs=1M count=10
dd: closing output file `toomuch': Input/output error
```

Nice 

But when I enabled rquotad in inetd on the server just like the OP suggests, then run *quota* for the "nfsuser", I get the same results, no quota. - Also tried adding 
	
	



```
options QUOTA
```
 to my kernel config, but that didn't help.

I looked at /usr/src/libexec/rpc.rquotad/rquotad.c which calls quota_read() in /usr/src/lib/libutil/quotafile.c -- but couldn't find any info on how it should work or not yet.. gtg now, will look at it more tonight.


----------

