Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have following scenarios:

Single partition mounted as /, with lots of disk space.

There is a range of directories (/pg/tbs1, /pg/tbs2, /pg/tbs3 and so on), and I would like to limit total size of these directories.

One option is to make some big files, and then mkfs them, and mount over loopback, and then set quota, but this makes expansion a bit problematic.

Is there any other way to make the quota work per directory?

share|improve this question
Mounting files via loopback doesn't really present an expansion problem. You would simply extend the underlying file and then use resize2fs to grow the filesystem. I think using LVM is a better solution, but the one you proposed does not have the limitations you think it does. – larsks Jan 7 '11 at 16:12
also btrfs and zfs – hanshenrik Apr 16 at 11:04
up vote 14 down vote accepted

If you're forced to use ext3, then using LVM is probably your best solution. Create a new filesystem per project. That would look something like this:

# Create a 10g filesystem for "project1" in volume group "vg0"
lvcreate -L 10g -n project1 vg0

# Create an ext3 filesystem.
mke2fs -j /dev/vg0/project1

# Mount it (obviously you would want this in /etc/fstab)
mount /dev/vg0/project1 /projects/project1

Growing the project filesystems is easy:

# Add 2GB to the volume.
lvextend -L +2g /dev/vg0/project1

# Grow the filesystem.
resize2fs /dev/vg0/project1
share|improve this answer

If you don't rely on group permissions, you can use a different UNIX group for each "quota directory", then set sgid bit on each directory (so created files and directories will belong to the group of the directory instead of the primary group of the creator user), and use group quotas.

share|improve this answer

Yes. Look at XFS filesystem and project quota. Other filesystem do not offer this feature.

share|improve this answer
Unfortunately I can't change underlying fs. But it's good to know that XFS has this capability. – user13185 Jan 7 '10 at 21:21

I've actually wanted to do this for a while because I didn't want to have to make system users for all of my virtual mail users. ZFS filesystems with quotas would be great, and zfs-fuse makes progress every day, but what I wanted was a very lightweight solution. Finally I decided to write a FUSE filesystem that I could mount as a layer over another filesystem (any base directory will work actually). It has a utility for managing quotas that can be scripted with easily and since quota values are just stored as xattrs on directories or files, one mountpoint can provide support for an arbitrary number of quotas.

I've been testing it on a mail server for a while and recently decided it had reached adolescence and was ready to release into the wild. If you're curious, you can check it out at I would greatly appreciate any feedback.

share|improve this answer

I am not aware of any method to set quotes per directory.

But along your idea of creating file-systems with a limited size. This might be a place where lvm would be a good solution.

You could backup/reinstall and use lvm, only allocating the minimum amount of space needed to your logical volumes. It is very easy to extend lvm logical volumes.

share|improve this answer

New filesystem for each shared folder is IMHO overkill. Just make new group for each shared folder, set owner group of shared folder to this group, set a sticky bit to group (so that every new file and directory has this group as owner )and for permissions on files and folders use acl lists. Then set quotas for these groups.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.