What is a "loop device" when mounting?
Solution 1
A 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 an entire filesystem, so you use loop.
The -o
is short for --options
.
And the last thing, if you want to search for "-o" you need to escape the '-'.
Try:
man mount | grep "\-o"
Solution 2
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.
Solution 3
Loop device is a device driver that allows you to mount a file that acts as a block device (a loop device is not actually a device type, it's an ordinary file).
For example:
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.
Related videos on Youtube
![Vass](https://i.stack.imgur.com/VJMpT.jpg?s=256&g=1)
Vass
Updated on September 17, 2022Comments
-
Vass almost 2 years
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 doman mount | grep "-o"
I get an error, and when I look in the file I do not find any info that "loop" is a command text for option-o
. Where is that documented?Also, what is the "loop device" concept for mounting?
-
Admin almost 7 yearsIn
man
you can search for a string by typing/mystring
after man starts. You can highlight all matches with just/
. Seeman man
. I see @Josh has added such a comment to the accepted answer. -
Admin over 6 yearsFor a related question I wrote a short outline of the concept
-
Admin almost 4 years
/
is the standard search feature in vi, vim and almost all commands that output in pages (less, more...)
-
ephemient over 13 yearsWith GNU grep,
grep -e -o
(-e
says "next thing is the pattern no matter what it looks like) orgrep -- -o
(--
means stop looking for switches) work too. Of course feel free to use whatever works for you. -
Hugo over 13 yearsYou can also just type:
man mount
, and then you can use/-o
to search for and highlight all instances of "-o" -
Louis Kröger almost 8 yearsAlthough this makes sense, it seems that providing the
loop
option is not required. -
Admin about 2 yearsYou should probably ask this as a new question.