This description is based on the following links: https://thelinuxexperiment.com/create-a-virtual-hard-drive-volume-within-a-file-in-linux/ http://linuxgazette.net/109/chirico.html http://stackoverflow.com/a/8148831 http://www.tecmint.com/set-access-control-lists-acls-and-disk-quotas-for-users-groups/
# sudo apt install quota
# mkdir -p /var/diskimg
# dd if=/dev/zero of=/var/diskimg/virtfs.img bs=1M count=100000
Comment: dd uses a block size of 512 bytes by default and we can change to 1M.
# mkfs -t ext4 /var/diskimg/virtfs.img
# mount /var/diskimg/virtfs.img /srv -t auto -o usrquota,grpquota,acl,loop=/dev/loop3
# quotacheck -mcuvgf /srv
# quotaon -vu /srv
# quotaon -vg /srv
Comment: the quotacheck scans a filesystem for disk usage, create, check and repair quota files. (The switch -f forces checking and writing of new quota files on filesystems with quotas enabled.)
# setquota -u $uid 10G 10G 0 0 /dev/loop3
Comment: the format (after $uid) is block-softlimit block-hardlimit inode-softlimit inode-hardlimit. To disable a quota, set the corresponding parameter to 0.