47

I am mounting an iso file, and looking at this tutorial. They use the command:

$ mount -o loop disk1.iso /mnt/disk

I'm trying to understand the use of -o loop. I have two questions:

When I look at the long man page for mount, it takes time to find that -o option. If I do man mount | grep "-o" I get and error, and when I look in the file I do not find info that "loop" is a command text for option -o. Where is that documented?

Also, what is the "loop device" concept for mounting?

  • I went to the same tutorial and had the same doubts, but almost after 6 years after you asked this question. :P – 7_R3X Aug 13 '16 at 14:06
  • 1
    In man you can search for a string by typing /mystring after man starts. You can highlight all matches with just /. See man man. I see @Josh has added such a comment to the accepted answer. – andy256 Sep 12 '17 at 2:41
  • For a related question I wrote a short outline of the concept – Bananguin Apr 3 '18 at 9:25
35

loop device is a pseudo ("fake") device (actually just a file) that acts as a block-based device. You want to mount a file (disk1.iso) that will act as entire filesystem, so you use loop.

The -o comes from the -options.

And the last thing, if you want to search for "-o" you need to escape the '-'. Try:

man mount | grep "\-o"
  • 2
    With GNU grep, grep -e -o (-e says "next thing is the pattern no matter what it looks like) or grep -- -o (-- means stop looking for switches) work too. Of course feel free to use whatever works for you. – ephemient Dec 6 '10 at 0:26
  • 7
    You can also just type: man mount, and then you can use /-o to search for and highlight all instances of "-o" – Josh Dec 7 '10 at 14:21
  • Although this makes sense, it seems that providing the loop option is not required. – sherrellbc Aug 5 '16 at 15:49
25

Traditionally, UNIX systems have had various types of nodes in their filesystems:

  • directory
  • file
  • symlink
  • block device
  • character device
  • FIFO
  • UNIX domain socket

While there are now exceptions, generally block devices containing filesystems are mounted on directories.

Since you want to mount a file, you must first create a loop block device that is backed by the file. This can be done using losetup, but mount -o loop is a shortcut that handles that behind the scenes.

  • Thank you for providing the various kind of UNIX node types. Very helpful to get the idea. – Alexandre Bourlier Jan 5 '17 at 20:05
1

Loop device is a device driver that allows you to mount a file act as a block device ( loop device is not actually device type.it's an ordinary file ). For example : file :demo.img

mount -o loop demo.img /mnt/DEMO/ 
ls -l /mnt/DEMO/ 

You can now look at the /mnt/DEMO subdirectory for the contents of the demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.