I am trying understand what the difference is between two ways of creating a loop
mount point. Now I can create this with:
sudo mount -o loop /file_to_use /mntpoint
, andsudo losetup /dev/loop1 /file_to_use
and then mountsudo mount /dev/loop1 /mntpoint
Question:
Are these the two processes the same as I have tested them and there both result in the same mount points as seen here, but I could be wrong?
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ext4 7af461fe-8d2d-4499-a12a-72ff586ff5d6 /boot
├─sda2 swap 44744c25-8797-4cd2-b83e-f129e97efc85 [SWAP]
├─sda3 ext4 3d39068d-96da-4f90-be42-b0921fb7278e /
└─sda4 ext4 643c8738-9823-43cd-b2b2-efe0b81b7611 /home
sr0
loop0 ext4 ac7deda8-7f3b-4835-8308-e4020ffe5302 /mnt/vfs
loop1 ext4 68a0676b-ad59-4dff-9c50-eca5d972c1c7 /mnt/tempdir
mount
tries to find first unused loop device just likelosetup
, unless you specify a specific path. you can control a loop device created bymount
usinglosetup
however something inmount
man page is interesting:The loop option with the offset or sizelimit options used may fail when using older kernels if the mount command can't confirm that the size of the block device has been configured as requested This situation can be worked around by using the losetup command manually before calling mount with the configured loop deviceloop
option ofmount
command is trying to do all the necessary stuff while we are running it so we don't have to manage theloop
devices our self. Also it has to be able to do this (Managing loop devices). So it will be able to use this ability when it's necessary to mount a device but user doesn't know that.