If you mean a filesystem in a file, it sounds like you're talking about using loop devices.
You'd do it something like this
Code:
dd if=/dev/zero bs=4G of=/var/filesys_in_a_file.fs
losetup /dev/loop0 /var/filesys_in_a_file.fs
mke2fs /dev/loop0
mount /dev/loop0 /media/loopfilesys
The red bits you'd only do the once when you first create the filesystem. For mounting a loopback filesystem that you've already created there a '-o loop' option on the mount command to shortcut needing to use the losetup command.
Hope that helps...
PS. I don't know how you'd make it's size dynamic. Is it even possible?