Jeff McAdams on 5 Jun 2007 02:11:11 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] /dev/loop/0 only once?


Jeff Abrahamson wrote:
> I was surprised to find that I can only mount one ISO image at a time:

>     # mount -t iso9660 -o ro,loop=/dev/loop/0 debian-cd-1.iso debian-cd-1

> Try that again without an intervening umount and I'm told device
> busy.  E.g., I want to look at 

>     # mount -t iso9660 -o ro,loop=/dev/loop/0 debian-cd-2.iso debian-cd-2

> Sure enough, there's no /dev/loop/1, but why should I need it?

> I don't really need to do it, though it would be nice.  But I'd really
> like to debug my understanding of mount.  I thought this should work.

No, it won't.  Basically, the loopback mount takes a filesystem image
(such as in the iso) and binds it to a device so that you can work with
it using Linux's device handling.  So, think about it a second, when you
bind /dev/loop/0 to debian-cd-1.iso, that let's you deal with
/dev/loop/0 as a device with a filesystem to be mounted, the filesystem
is in debian-cd-1.iso, of course.  When you issue the second command,
you're telling it to use /dev/loop/0 to access the filesystem in
debian-cd-2.iso...but its still being using to access the filesystem in
debian-cd-1.iso.  So, when you do further operations...which file would
it do the operations in?  So, you're asking it to do fundamentally
contradictory things.

What you should be able to do for a second command is
# mount -o ro /dev/loop/0 debian-cd-2

That will give you a second mount point to access the same filesystem,
but I doubt you'll find that very useful.

So, hopefully that helps you understand why you need /dev/loop/1 in that
case.  With /dev/loop/1 in addition to /dev/loop/0 you can do what you
need.  You can use the mknod command to create further /dev/loop/*
devices, they're block devices with major number 7, and minor numbers
starting at 0 and incrementing (typically).
-- 
Jeff McAdams
"They that can give up essential liberty to obtain a
little temporary safety deserve neither liberty nor safety."
                                       -- Benjamin Franklin

Attachment: signature.asc
Description: OpenPGP digital signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug