Under some OperatingSystems (especially Unix-like ones), you can mount(8) a single file onto your VirtualFileSystem. There are several reasons why you might want to do this:
This is what I did to make sure to test that my software failed gracefully when disk space ran out.
1) Create a file containing a filesystem
create a 2 MB file with an ext2 filesystem $ dd if=/dev/zero of=/tmp/loop.fs bs=1M count=2 $ mke2fs -F /tmp/loop.fs
2) mount it as a loop back device (must be done as root)
load the loop.ko kernel module if support is not compiled into the kernel # modprobe loop where I want it to be mounted # mount /tmp/loop.fs /mnt/directory -o loop
Now /mnt/directory will only allow around 2MB (minus filesystem overhead) of data to be written to it, and then the device will be out of space.
One page links to LoopDevice: