16

Usually, quotas are enforced per user, as related to the proprietary of the file.

Is it possible to apply a quota on a folder basis, in such a way, that a folder contents are limited in disk space?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Lorenz Meyer
  • 470
  • 2
  • 5
  • 13

1 Answers1

6

Same question asked and answered over here:

https://stackoverflow.com/questions/8148715/how-to-set-limit-on-directory-size-in-linux

basically, make a virtual filesystem by filling a file with zeros to the size you want, then create a filesystem in that file and then loopmount it to the directory you want to limit.

Linux Quartly article about it here: http://www.linuxquestions.org/questions/linux-server-73/directory-quota-601140/

Tutorial here: http://souptonuts.sourceforge.net/quota_tutorial.html

Mike Diehn
  • 1,008
  • 6
  • 7
  • 2
    OK, but this reserves the space form the beginning. It really does not help to save disk space. Does this mean, that there is **NO** solution to this problem that keeps used disk space minimal ? – Lorenz Meyer Nov 07 '13 at 09:28
  • 3
    @LorenzMeyer: You can limit the use of actually used diskspace by using a sparse-file instead of a full-fledged file. Though you can easy run [into trouble](http://en.wikipedia.org/wiki/Sparse_file#Disadvantages) when the disk space on the *real HDD* runs out. E.g. `truncate -s 512M foo;` The filesystem (e.g. ext3) is going to make the file less sparse but the ocupied size is still much lower. E.g. a 100MiB sparse file ocupy about 7.7 MiB of space after it has been formatted with ext3. – Runium Nov 07 '13 at 10:07