So here is how to do it..
Virtual devices are achieved in linux using loop devices.
To create a new loop device, we use the losetup command. For eg. say we need to mount the cd image file /temp/varmathe/damn-small-linux.iso ad a cd drive. Here is how to do it.
1. Locate the first available loop device
2. Associate this device node to the iso fileopensuse103-vm:/temp/varmathe # losetup -f
/dev/loop0
3. Now mount the cd somewhere on our filesystem hierarchy.opensuse103-vm:/temp/varmathe # losetup /dev/loop0 damn-small-linux-3.4.4.iso
Additionally, it might be a wise idea to mount cd/dvd images etc as read only..opensuse103-vm:/temp/varmathe # mount -t iso9660 /dev/loop0 /mnt/vcd
opensuse103-vm:/temp/varmathe # cd /mnt/vcd
opensuse103-vm:/mnt/vcd # ls
boot index.html KNOPPIX lost+found
4. Use the volume.. (he he :D )
5. Now that we are done and want to unmount the device and release the file
The -d option detaches the file from the loop deviceopensuse103-vm:/temp/varmathe # umount /mnt/vcd
opensuse103-vm:/temp/varmathe # losetup -d /dev/loop0
Steps 1,2, and 3 can be combined into a single step as
While the above single step approach looks like it should have been explained first; I deliberately explained the broken approach for a reason. If you only need the device node, say for eg, to pass that on to a virtual machine; then you don't need to do the mount.. The "losetup" steps alone would do.opensuse103-vm:/home/varmathe # mount -t iso9660 -o loop /temp/varmathe/damn-small-linux-3.4.4.iso /mnt/vcd
.