# help: to limit a folde`s size without using quotas

## gustavolinux

Friends, could anybody there give me a light, please, to solve the following problem: I need a way to limit the size of a folder, but without using group or user quotas... is there a good solution?

For example, I want to avoid that folder X grows up more than 100MiB, no matters who writes to the folder...

If there is no such way, maybe do you think that it is possible to create a new user account just to control the size of the folder X? I mean to put this new user as the owner of the folder X and allow any access to the folder... Do you think that, if someone writes to the folder, the quota of the new user would be consumed and reach an unbreakable limit?

thanks in advance

----------

## timeBandit

The first thing that comes to mind is to create and mount a loopback filesystem on the size-restricted folder. Allow a little extra space in the file for filesystem overhead. For example, something like this:

```
# dd if=/dev/zero of=/var/lib/sandbox.ext3 bs=1048576 count=106

# losetup /dev/loop0 /var/lib/sandbox.ext3

# mke2fs -j /dev/loop0

# mkdir /mnt/sandbox

# mount /dev/loop0 /mnt/sandbox
```

This creates a a 100MB filesystem in the file /var/lib/sandbox and mounts it on /mnt/sandbox.

This requires loopback support enabled in your kernel. Future mounts are simpler: mount -o loop /var/lib/sandbox.ext3 /mnt/sandbox. To have it mounted at every boot, edit /etc/fstab as required (be sure to include loop in the options column) and ensure the loop device module is loaded at startup (if you compiled it as a module).

Also: Welcome to the forums and please read and heed our Guidelines--in particular, item #12 regarding cross-posts. I do not speak Portuguese but nonetheless recognized that you asked the same question earlier today.   :Wink: 

----------

## gustavolinux

thanks timeBandit, I will have to study your answer, because I'm not that sharp with linux... 

sorry about the cross posts... I think I did it again before reading your answer  :Sad: 

the post "setgid e controle de quota de um diretório"

https://forums.gentoo.org/viewtopic-p-5182441.html#5182441

is related.. (only posted in portuguese)

thanks again

----------

## gustavolinux

just to give a feedback: a loop device was a really good idea... to every folder that I want to limit its size I create an image of a file system with the right size... []'s

----------

