How can I use quotas in samba?
I have a simple set-up with just one public share on my configuration file. How can I restrict its size?
Solution 1:
There are a couple of ways to achieve this.
The general method for applying proper per-user quotas is to configure a Linux quota (similar how-to for Ubuntu 7.x) on all users that access the public share. Samba doesn't handle the quotas directly; the quotas are applied to the users on a given filesystem, meaning the effective UID that their Samba connections operate as, which might be guest or nobody for a public share.
A simple way to restrict the size is put your public share on its own small filesystem. Create a partition from free space on your harddrive, format it, mount it somewhere, and move your share to somewhere under that mountpoint. If your users fill that filesystem, they'll have filled their "quota", and other partitions on your system won't be affected.
A hackish way that I think will work is to create a virtual filesystem (imagine an ext3-formatted ISO image) in the maximum size for the share. This is basically the same as above, except instead of a separate partition, you've just created a single file of, say, 10GB (if you want 10GB of space available to the share). You'll mount that image file as a loopback device, and place the share under its mountpoint. Again, you don't have to configure a quota; the filesystem size is set when you create the image file, and if your users fill it up it won't impact the rest of the system.