I have a iso file named ubuntu.iso
.
I can mount
it with the command: mount ubuntu.iso /mnt
. After mounting it, I can see it from the outout of the command df -h
: /dev/loop0 825M 825M 0 100% /mnt
.
However, if I execute the command mount -o loop ubuntu.iso /mnt
, I'll get the same result.
As I know, loop device allows us to visit the iso file as a device, I think this is why we add the option -o loop
. But I can visit my iso file even if I only execute mount ubuntu.iso /mnt
.
So I can't see the difference between mount
and mount -o loop
.
Best Answer
Both versions use loop devices, and produce the same result; the short version relies on “cleverness” added to
mount
in recent years.mount -o loop
tellsmount
explicitly to use a loop device; it leaves the loop device itself up tomount
, which will look for an available device, set it up, and use that. (You can specify the device too with e.g.mount -o loop=/dev/loop1
.)The cleverness is that, when given a file to mount,
mount
will automatically use a loop device to mount it when necessary — i.e., the file system isn’t specified, orlibblkid
determines that the file system is only supported on block devices (and therefore a loop device is needed to translate the file into a block device).The loop device section of the
mount
man page has more details.