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:
- create the mount point
- create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual filesystem
- 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)
- 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
- Set proper permissions
- 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.