В Linux можно ограничить размер раздела, например с квотой. Но существует ли способ ограничить размер каталога?
Например, у меня есть каталог, скажем / mnt / foo / bar
, который не является разделом (например, не в df
результат). Возможно ли это?
Нет mkfs
в этом каталоге.
Не напрямую, вы можете создать файл того размера, которым вы хотите ограничить каталог, а затем смонтировать его, используя монтирование цикла в дерево.
fallocate -l 100M disk.img
(это не всегда совместимо с базовой FS). dd if = / dev / zero of = disk.img count = 512k
mkfs disk.img
mount -o loop disk.img / path / to / mount / point
(при желании вы также можете включить квоты) What you are asking for would be a nice feature, but I am not aware of any file system with such a feature. The best approximation without adding more file systems would be to use quotas, which limit storage space per user (or group).
One problem with doing it per directory is that the semantics are not going to be obvious, once you consider the possibility that a file may be hardlinked.
Consider the following sequence of events:
user1
run a program, which creates a logfile in ~user1
user2
creates a hardlink in ~user2
user2
adds 900MB of other files to ~user2
user1
appends 900MB of data to the logfileuser1
deletes the logfile from ~user1
There is not any one single of the above operations, you would expect to fail due to quota limits. Yet the outcome is that user2
is way above quota in the end.