Explanation of the "loop" option when mounting CD image files
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Explanation of the "loop" option when mounting CD image files
Hi there,
I've read that one can mount CD iso files using the mount command e.g.
Code:
# mount -t iso9660 -o ro,loop=/dev/loop0 cd.iso /mnt/cdrom
Could someone kindly explain the purpose and function of the loop=/dev/loop0 section of the command and why it is explicitly used when mounting cd ISOs ? I always find it's role a mystery
The loop option means loop-back. Since there is no real device file in /dev for filesystems which exists only inside in a file, the kernel provides these loopback devices which act as a conduit for the filesystem-in-a-file.
I think it's not usually necessary to specify which one to use - you can usually just say "-o loop". Also, the ro option (readonly) is not necessary as the CD filesystem cannot be written to anyway. Lastly, the filesystem type will probably be determined automatically, so you might not need the -t option either. Hence this should do the same thing as your command with a little less typing:
Thanks matthew ! Is there any other scenario a linux user could encounter which involves mounting using the loop option ? One which does not involve iso / CDs.
You might have an image of hard disk (a byte-for-byte copy of the whole device or partition to a file). You can mount these images using the loop option.
Is there any other scenario a linux user could encounter which involves mounting using the loop option?
I used loop-back devices to setup a disk space with quotas (see this post for a more detailed explanation) or to share some directories on a file server to make them available to specific users only (without data replication).
You might also use a loopback device to have an encrypted filesystem in a file with sensitive document is, although there's no reason to use a loopback other than as an alternative to a real partition.
An alternative to this is to use the fuse-based EncFS.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.