I'm doing a study about how CD-ROM can be mounted virtually and all I could find out was mounting using loop devices.
mount -o loop disk1.iso /mount-point
This is fairly easy.
I understand that /dev/sr0
is a block device and it point to some buffer in kernel and the kernel device driver puts the filesystem (ot whatever it puts i am not sure) in that buffer and when we use mount
it mounts the filesystem to the specified mount-point.
But am wondering whether we can mount an ISO of our choice (e.g. disk1.iso
) by using SCSI CD-ROM device /dev/sr0
(without changing anything in the kernel) as it is done in Vmware and Virtualbox, where we can specify the ISO and it automatically emulates a CD-ROM hardware and the ISO can be mounted using /dev/sr0
device?
The major problem which i see here is that how /dev/sr0/
will be linked to the iso?
Best Answer
The thing here is that
/dev/sr0
is linked to a kernel device driver. That device driver will allow access to a physical CDROM if available through that node; VMWare and VirtualBox emulate hardware as you mention and hence the kernel and device driver think they're communicating with hardware.The
/dev/sr0
doesn't point to a certain buffer directly, it provides an interface to the block device interface that allows userspace processes to acces the contents of the hardware device.If you want to make an image available as a block device, then your only choice (besides virtualization and emulating hardware) is to use loop devices with
losetup
... or to write your own replacement device driver, but I expect that's not a viable option for now.If you want to make that image available as
/dev/sr0
(are we talking about faking out some software that demands access to a CDROM at that location?) then you could move that file to e.g./dev/sr0.moved
and then symlink the appropriate/dev/loopX
to/dev/sr0
. Of course, if the software in question tries special commands that only apply to CDROM devices, then this won't work. Otherwise it shouldn't be a problem.