How to set limit on directory size in Linux? [closed]

[亡魂溺海] 提交于 2019-11-28 16:43:45

问题


I have read about limiting size of directory - like creating big files, formatting,mount,.. etc. But this all very complicated. Does exist utility or something else to set limit on already existing directory?


回答1:


Quota is based upon filesystems, but you can always create a virtual filesystem and mount it on a specific (empty) directory with the usrquota and/or grpquota flags.

In steps this will be:

  1. create the mount point
  2. create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual filesystem
  3. format this file with an ext3 filesystem (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
  4. mount the newly formatted disk space in the directory you've created as mount point, e.g. Code: mount -o loop,rw,usrquota,grpquota /path/to/the/formatted/disk/space /path/of/mount/point
  5. Set proper permissions
  6. Set quotas and the trick is done.

Tutorial here. Original answer here




回答2:


You could limit the quota on a filesystem. But it is not directory specific, but file system & user specific.

You might also consider developping your own user space file system using FUSE, but this will take your time.



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!