The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.