$ dd if=/dev/zero of=imagefile bs=2048 count=1024
1024+0 records in
1024+0 records out
2097152 bytes (2.1 MB) copied, 0.015324 seconds, 137 MB/s
$ mke2fs imagefile
mke2fs 1.39 (29-May-2006)
imagefile is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
256 inodes, 2048 blocks
102 blocks (4.98%) reserved for the super user
First data block=1
Maximum filesystem blocks=2097152
1 block group
8192 blocks per group, 8192 fragments per group
256 inodes per group
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
$ sudo mount -o loop imagefile /mnt/
$ ls /mnt/
$ vi /mnt/somefile
$ ls /mnt
lost+found somefile
$ mount
/home/akaedu/imagefile on /mnt type ext2 (rw,loop=/dev/loop0)
$ sudo umount /mnt