How to use the loop device on Unix?
The loop device on Unix lets access a file as a block device. Disks are block devices. So, it is possible to use a file as a disk. The first step, create a file that will be used as a disk.
dd if=/dev/zero bs=1M count=100 of=/tmp/mydiskfile
Format your file as a file system. If /dev/loop0 is already used, use /dev/loop1.
losetup /dev/loop0 /tmp/mydiskfile mkfs.ext4 /dev/loop0 losetup -d /dev/loop0
losetup -d /dev/loop0 deletes the loop device
mount -o loop /tmp/mydiskfile /mnt
The file /tmp/mydiskfile can now be used as a disk with /mnt as the mount point!