Mount file as disk in Linux

An example of using dd to create a 1GB file.

dd if=/dev/zero of=testfile bs=1M count=1024

Or alternatively, create a sparse file ( very quick to create, but will lead to fragmentation later)

dd if=/dev/zero of=testfile bs=1M seek=1024 count=0

Large files can be formatted with a file system and mounted:

mkfs.ext3 -F testfile
mount -o loop -t ext3 testfile /mnt
umount /mnt
Mount file as disk in Linux