losetup

Used to manage loop devices, these are volumes contained in a file and not in a drive or partition eg. iso image file

package util-linux

Creating a new file volume

To create an empty container file

WARNING ! dd can overwrite your entire drive if you use the wrong Output File (of)

You can use if=/dev/random for more security but it takes longer

Setup a loop device

Make the container file available for mounting as the next available loop device number

You can use the Disk Utility or cryptsetup on a loop device that has been setup

Copying a drive/partition into a file volume

WARNING ! dd can overwrite your entire drive if you use the wrong Output File (of)

You can make an iso image of a cdrom by using if=/dev/cdrom or if=/dev/sd0

Closing a loop device

After you have unmounted the volume

Since Linux version 2.6.25 auto-destruction of loop devices are supported, any loop device allocated by mount will be freed by umount independently on /etc/mtab

Otherwise you can manually free a loop device