• Create the mount point
mkdir /var/virtual_disks/directory_with_size_limit
  • Create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual file-system
touch /var/virtual_disks/directory_with_size_limit.ext3
dd if=/dev/zero of=/var/virtual_disks/directory_with_size_limit.ext3 bs=QUOTA_SIZE count=1
  • Format this file with an ext3 file-system (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
mkfs.ext3 /var/virtual_disks/directory_with_size_limit.ext3
  • Mount the newly formatted disk space in the directory you've created as mount point, e.g.
mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
  • As a result you now have a directory in /path/of/mount/point with a size limitation.

If you wish to add more space to (trim the size of the directory):

umount /path/of/mount/point
e2fsck -f /var/virtual_disks/directory_with_size_limit.ext3
resize2fs -p /var/virtual_disks/directory_with_size_limit.ext3 NEW_SIZE
mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License