I know I can create and use a loopback device like this:
# Create the file
truncate disk.img --size 2G
# Create a filesystem
mkfs.ext4 disk.img
# Mount to use
mount disk.img /mnt
# Clean up
umount /mnt
However in this case the disk image is fixed at 2GB. It's 2GB when it's empty, and it's 2GB when it's full. It will not grow.
Is there a kind of loopback device that can grow in size? Or, is there a kind of loopback device that only needs as much space that it stores?
virt-make-fs
might be useful. It can be used to create ext2-images using tar files. – Kotte Dec 12 '13 at 22:37