I want to limit the size of folder, so that a process cannot write more then x MB
data to that folder. Looks like its not possible to do this in linux for folders but it can be done on tempfs filesystem
.
So i can create a tempfs filesystem and set a size limit on it.
But the problem is tempfs
is backed by RAM (and swap) which is not acceptable for my case as i will run out of disk space. Can i back the tempfs with a existing folder on disk?
I want to create around 50 such directories and set a cap of 500MB on each of those.
EDIT 1: What does following command do?
sudo mount -t tmpfs /tmp /tmp/mnt/aks2
I guess it mounts folder /tmp
as mountpoint /tmp/mnt/aks2
. Does that mean /tmp/mnt/aks2
mount point is backed by /tmp folder instead of RAM? If yes why do i -t tmpfs in the command?
No. Just create a filesystem in a file of the maximum size desired and loopmount that instead.
e.g.: