I would like to implement per-directory quotas for a multi-user web application we're developing. The problem is... we have implemented a document manager for any client to store their own private documents but we don't want to run out of space due to this feature, so we want to assign them a given limit.
As there doesn't seem to exist a standard method for implementing per-directory quotas in Linux (I know, quotas are primarily targeted against users or groups, but we need something like the way Windows Server 2008 R2 handles quotas on a per-directory basis) I opted to use a 'trick'. I basically do this:
touch client1.ext3
dd if=/dev/zero of=./client1.ext3 bs=1024 count=16384
mkfs.ext3 ./client1.ext3
mount -o loop,rw ./client1.ext3 ./mountpoint
It's just a code sample, but that's the idea... I create virtual 'volumes' which I assign to my clients so they can store their private data and, in case they need more, they can pay on a per-storage-ammount basis.
The 'problem' I see with this is I just see 8 loop devices in my /dev hierarchy, and we currently have 17 test clients for our application, so the ammount of currently present loop devices don't cover my needs. I know you could allocate up to 256 loop devices up to kernel version 2.6.23, and the limit (from version 2.6.24 onwards) isn't theoretically present anymore, although I still have some concerns.
Honestly, I feel like filling the /dev hierarchy with 1000+ loop devices (which are not gonna be unmounted at all during all the system lifetime) is very wrong and not the way it should be done, but maybe it's doable as a middle-term solution, so my questions are:
The idea you described is in fact "logical volume management" (LVM) done by hand. If you use LVM for this you get the double bonus of "it's a well known standard" and "there is good tool support for that including online resizing and more".