One further possible type is a mount via the loop device. For
example, the command
mount /tmp/disk.img /mnt -t vfat -o loop=/dev/loop3
will set up the loop device /dev/loop3 to correspond to the file
/tmp/disk.img, and then mount this device on /mnt.
If no explicit loop device is mentioned (but just an option '-o
loop
' is given), then mount
will try to find some unused loop
device and use that, for example
mount /tmp/disk.img /mnt -o loop
The mount
command automatically
creates a loop device from a
regular file if a filesystem type is not specified or the
filesystem is known for libblkid, for example:
mount /tmp/disk.img /mnt
mount -t ext4 /tmp/disk.img /mnt
This type of mount knows about three options, namely loop
, offset
and sizelimit
, that are really options to losetup(8). (These
options can be used in addition to those specific to the
filesystem type.)
Since Linux 2.6.25 auto-destruction of loop devices is supported,
meaning that any loop device allocated by mount
will be freed by
umount
independently of /etc/mtab.
You can also free a loop device by hand, using losetup -d
or
umount -d
.
Since util-linux v2.29, mount
re-uses the loop device rather than
initializing a new device if the same backing file is already
used for some loop device with the same offset and sizelimit.
This is necessary to avoid a filesystem corruption.