Occasionally you may need to create a virtual filesystem to simulate adding a quota to a directory. For example you are looking after a system which does not have volume management configured and an application keeps on filling up a critical file system with logs or temp files.
With this solution you can create a virtual filesystem to contain those files to prevent a full filesystem affecting other applications or the O/S.
- Create a mount point
# mkdir /myapplogfiles
- Create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual file-system – modify dir names and locations as required.# dd if=/dev/zero of=/virtdisks/virtdiskfile.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 before initiating)# mkfs.ext3 /virtdisks/virtdiskfile.ext3
- Mount the formatted file onto the directory you’ve created as mount point, e.g.# mount -o loop,rw,usrquota,grpquota /virtdisks/virtdiskfile.ext3 /myapplogfilesAs a result you now have a directory in /myapplogfiles with a pre-configured maximum size.
You can modify (increase) size of the filesystem as well.
# umount /myapplogfiles
# e2fsck -f /virtdisks/virtdiskfile.ext3
# resize2fs -p /virtdisks/virtdiskfile.ext3 NEW_SIZE
# mount -o loop,rw,usrquota,grpquota /virtdisks/virtdiskfile.ext3 /myapplogfiles
- It is wise to document your ‘adhoc’ filesystem so other sysadmins know why this has been done. Also be aware that this uses space in the host filesystem.
- When you upgrade the system – install LVM!