FreeBSD set quota for users per ZFS share

I create a pool named storage. I have multiple folders on it and users connect to them via Samba and SFTP.

I want to set quota for users, and this quota is different for every shares.

example:

user1 has 10G on /storage/folder1

usser2 has 1G on /storage/folder1

user1 has 5G on /storage/folder2

user1 has 100M /storage/folder3 . . .

I'm on FreeBSD11.

Thanks for tour help.
 
Last edited by a moderator:
Doing this with zfs set quota would require creating one dataset per user and setting a quota on each one. You can try using quota(1) to set quotas per user. Though I've never used it myself, the man page suggests it's filesystem-agnostic.
 
Actually...

There is a native option to set quotas on a per-user basis, from zfs(8):

Code:
     userquota@user=size | none
         Limits the amount of space consumed by the specified user.  Similar
         to the refquota property, the userquota space calculation does not
         include space that is used by descendent datasets, such as snapshots
         and clones. User space consumption is identified by the
         userspace@user property.
Theoretically this should work, but last time I tried (a few years back, so maybe not fully relevant) I eventually moved back to setting up dedicated filesystems for the users.

Even so, I'd try this before attempting something with quota.
 
Thanks for your responses

creating one dataset per user and setting a quota on each one

userquota@user=size | none

I create one dataset and setting quota for three users. But I faced with some problems:

1. Sometimes the data size that transfered were more than the size I declared.
2. When I want to transfer data the zfs quota doesn't notice to space that remain and transfer stops after the space fills up.
3. When space fills up, it doesn't allow the user(owner) to delete the files.

Thank you again for your help.
 
I create one dataset and setting quota for three users. But I faced with some problems:

1. Sometimes the data size that transfered were more than the size I declared.
2. When I want to transfer data the zfs quota doesn't notice to space that remain and transfer stops after the space fills up.
3. When space fills up, it doesn't allow the user(owner) to delete the files.

I would go the one dataset per user route. As the zfs(8) page states regarding userquota:

Code:
Enforcement of user quotas may be delayed by several seconds. This delay means that a user might exceed their quota before the system notices that they are over quota and begins to refuse additional writes with the EDQUOT error message.

Try per-user datasets with refquota settings. I personally avoid quota settings as users can get wedged with snapshots that they are unable to remove (as normal users) using up their quota. (Unless you never use snapshots.) Per-user datasets are nice for other reasons (like being able to delete one user/share and its snapshots as a unit, and additional datasets are 'cheap' in ZFS.
 
Thanks for your help

I create a pool and instead of mkdir for my shares, create datasets in it and set qouta on every datasets.

1. Sometimes the data size that transfered were more than the size I declared.
2. When I want to transfer data the zfs quota doesn't notice to space that remain and transfer stops after the space fills up.
3. When space fills up, it doesn't allow the user(owner) to delete the files.

for solving problem #3, I set reservation for dataset.
problem #1 and #2 has remained.
I have problem in setting access list for datasets. I create another post for this problem.
Thank you again
 
Back
Top