What is the difference between mount and mount -o loop

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
20
down vote

favorite
2












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.










share|improve this question





















  • Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
    – illiterate
    Sep 6 at 7:39














up vote
20
down vote

favorite
2












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.










share|improve this question





















  • Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
    – illiterate
    Sep 6 at 7:39












up vote
20
down vote

favorite
2









up vote
20
down vote

favorite
2






2





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.










share|improve this question













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.







mount loop-device






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 5 at 7:19









Yves

818417




818417











  • Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
    – illiterate
    Sep 6 at 7:39
















  • Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
    – illiterate
    Sep 6 at 7:39















Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
– illiterate
Sep 6 at 7:39




Also a important thing is sometimes mount can't setup loopback device with appropriate arugments For example:mount ubuntu.iso /mnt it do not setup a read-only loopback device,and mount /image.squashfs /mnt it do not setup a DIO(losetup --direct-io=on)loopback device.
– illiterate
Sep 6 at 7:39










3 Answers
3






active

oldest

votes

















up vote
33
down vote



accepted










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 tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, 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, or libblkid 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.






share|improve this answer


















  • 1




    Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
    – Edheldil
    Sep 6 at 11:34










  • @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
    – Stephen Kitt
    Sep 6 at 11:56










  • Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
    – rackandboneman
    Sep 6 at 12:08






  • 1




    @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
    – Stephen Kitt
    Sep 6 at 12:41











  • An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
    – grawity
    Sep 7 at 6:31


















up vote
8
down vote













The loop device is primarily controlled with the losteup command. So losetup -a gives you overview about the used loop devices and attached files. The mount command can mount the block device only. The loop device can create the virtual block device from a file (character device).



In fact there is a great difference between those commands because on older Linux systems the mount could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print command) yoursef and than mount it with full option mount comman as :



mount disk_image.raw /mntpoint/ -o loop,offset=$OFFSET_of_PARTITION


In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0, /dev/loop1 etc)
Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660) if the filesystem support was installed.






share|improve this answer





























    up vote
    6
    down vote













    There is no difference between mount ubuntu.iso /mnt and mount -o loop ubuntu.iso /mnt.



    The first is transparently handled as if you had used the second.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466938%2fwhat-is-the-difference-between-mount-and-mount-o-loop%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      33
      down vote



      accepted










      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 tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, 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, or libblkid 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.






      share|improve this answer


















      • 1




        Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
        – Edheldil
        Sep 6 at 11:34










      • @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
        – Stephen Kitt
        Sep 6 at 11:56










      • Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
        – rackandboneman
        Sep 6 at 12:08






      • 1




        @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
        – Stephen Kitt
        Sep 6 at 12:41











      • An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
        – grawity
        Sep 7 at 6:31















      up vote
      33
      down vote



      accepted










      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 tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, 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, or libblkid 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.






      share|improve this answer


















      • 1




        Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
        – Edheldil
        Sep 6 at 11:34










      • @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
        – Stephen Kitt
        Sep 6 at 11:56










      • Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
        – rackandboneman
        Sep 6 at 12:08






      • 1




        @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
        – Stephen Kitt
        Sep 6 at 12:41











      • An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
        – grawity
        Sep 7 at 6:31













      up vote
      33
      down vote



      accepted







      up vote
      33
      down vote



      accepted






      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 tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, 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, or libblkid 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.






      share|improve this 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 tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, 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, or libblkid 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.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Sep 6 at 12:56

























      answered Sep 5 at 7:29









      Stephen Kitt

      147k22321389




      147k22321389







      • 1




        Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
        – Edheldil
        Sep 6 at 11:34










      • @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
        – Stephen Kitt
        Sep 6 at 11:56










      • Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
        – rackandboneman
        Sep 6 at 12:08






      • 1




        @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
        – Stephen Kitt
        Sep 6 at 12:41











      • An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
        – grawity
        Sep 7 at 6:31













      • 1




        Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
        – Edheldil
        Sep 6 at 11:34










      • @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
        – Stephen Kitt
        Sep 6 at 11:56










      • Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
        – rackandboneman
        Sep 6 at 12:08






      • 1




        @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
        – Stephen Kitt
        Sep 6 at 12:41











      • An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
        – grawity
        Sep 7 at 6:31








      1




      1




      Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
      – Edheldil
      Sep 6 at 11:34




      Not *that * long ago there was no "-o loop" option in mount either and you would have to manually create the loop device with losetup command.
      – Edheldil
      Sep 6 at 11:34












      @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
      – Stephen Kitt
      Sep 6 at 11:56




      @Edheldil that depends on your notion of “long ago” ;-). util-linux 2.11 supported mount -o loop in 2001, and I think 2.10 had it too, at least a year earlier.
      – Stephen Kitt
      Sep 6 at 11:56












      Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
      – rackandboneman
      Sep 6 at 12:08




      Yeah, but did commonly used stable distributions in 2001 use util-linux 2.11 already?
      – rackandboneman
      Sep 6 at 12:08




      1




      1




      @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
      – Stephen Kitt
      Sep 6 at 12:41





      @rackandboneman I went digging a bit more, and it turns out that support for -o loop was added sometime between util-linux 2.4 and 2.5j; Debian 1.1 had the latter and was released in June 1996. So this option has been available in distributions for over twenty years.
      – Stephen Kitt
      Sep 6 at 12:41













      An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
      – grawity
      Sep 7 at 6:31





      An advantage to this cleverness: if/when XFS developers' new "direct file mount" feature (without the need for loop devices) reaches the kernel, mount will be able to switch to that mechanism transparently (At least for the first 15 minutes until it turns out it broke somebody's shellscript and everyone has to go back to loop devices), unlike mount -o loop which still explicitly asks for the old (current) mechanism.
      – grawity
      Sep 7 at 6:31













      up vote
      8
      down vote













      The loop device is primarily controlled with the losteup command. So losetup -a gives you overview about the used loop devices and attached files. The mount command can mount the block device only. The loop device can create the virtual block device from a file (character device).



      In fact there is a great difference between those commands because on older Linux systems the mount could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print command) yoursef and than mount it with full option mount comman as :



      mount disk_image.raw /mntpoint/ -o loop,offset=$OFFSET_of_PARTITION


      In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0, /dev/loop1 etc)
      Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660) if the filesystem support was installed.






      share|improve this answer


























        up vote
        8
        down vote













        The loop device is primarily controlled with the losteup command. So losetup -a gives you overview about the used loop devices and attached files. The mount command can mount the block device only. The loop device can create the virtual block device from a file (character device).



        In fact there is a great difference between those commands because on older Linux systems the mount could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print command) yoursef and than mount it with full option mount comman as :



        mount disk_image.raw /mntpoint/ -o loop,offset=$OFFSET_of_PARTITION


        In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0, /dev/loop1 etc)
        Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660) if the filesystem support was installed.






        share|improve this answer
























          up vote
          8
          down vote










          up vote
          8
          down vote









          The loop device is primarily controlled with the losteup command. So losetup -a gives you overview about the used loop devices and attached files. The mount command can mount the block device only. The loop device can create the virtual block device from a file (character device).



          In fact there is a great difference between those commands because on older Linux systems the mount could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print command) yoursef and than mount it with full option mount comman as :



          mount disk_image.raw /mntpoint/ -o loop,offset=$OFFSET_of_PARTITION


          In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0, /dev/loop1 etc)
          Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660) if the filesystem support was installed.






          share|improve this answer














          The loop device is primarily controlled with the losteup command. So losetup -a gives you overview about the used loop devices and attached files. The mount command can mount the block device only. The loop device can create the virtual block device from a file (character device).



          In fact there is a great difference between those commands because on older Linux systems the mount could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print command) yoursef and than mount it with full option mount comman as :



          mount disk_image.raw /mntpoint/ -o loop,offset=$OFFSET_of_PARTITION


          In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0, /dev/loop1 etc)
          Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660) if the filesystem support was installed.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 15 at 16:07









          Rui F Ribeiro

          36.8k1273117




          36.8k1273117










          answered Sep 5 at 8:39









          schweik

          1804




          1804




















              up vote
              6
              down vote













              There is no difference between mount ubuntu.iso /mnt and mount -o loop ubuntu.iso /mnt.



              The first is transparently handled as if you had used the second.






              share|improve this answer
























                up vote
                6
                down vote













                There is no difference between mount ubuntu.iso /mnt and mount -o loop ubuntu.iso /mnt.



                The first is transparently handled as if you had used the second.






                share|improve this answer






















                  up vote
                  6
                  down vote










                  up vote
                  6
                  down vote









                  There is no difference between mount ubuntu.iso /mnt and mount -o loop ubuntu.iso /mnt.



                  The first is transparently handled as if you had used the second.






                  share|improve this answer












                  There is no difference between mount ubuntu.iso /mnt and mount -o loop ubuntu.iso /mnt.



                  The first is transparently handled as if you had used the second.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 5 at 7:28









                  Emmanuel Rosa

                  2,5701411




                  2,5701411



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466938%2fwhat-is-the-difference-between-mount-and-mount-o-loop%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      Peggy Mitchell

                      Palaiologos

                      The Forum (Inglewood, California)