Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to create a virtual cdrom device?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
germanobax
Tux's lil' helper
Tux's lil' helper


Joined: 28 Apr 2005
Posts: 96

PostPosted: Mon Dec 26, 2005 5:54 am    Post subject: How to create a virtual cdrom device? Reply with quote

I want to create a virtual device in /dev/ pretending to be a cdrom. Some programs try to look for /dev/cdrom, making impossible to just mount a ISO in some folder. I think it would be nice to have a way to map a image to a device and use it as some kind of virtual drive.

Can I do something like that?
_________________
Life is a Sexually Transmitted Disease, with 100% mortality.
Back to top
View user's profile Send private message
smithjd15
Tux's lil' helper
Tux's lil' helper


Joined: 12 Mar 2003
Posts: 130
Location: Edmonton, AB, CA

PostPosted: Mon Dec 26, 2005 9:02 am    Post subject: Reply with quote

How about mounting an iso image on loopback? try this:
Code:
# mount -o loop myiso.iso /mnt/virtualcdrom
Back to top
View user's profile Send private message
germanobax
Tux's lil' helper
Tux's lil' helper


Joined: 28 Apr 2005
Posts: 96

PostPosted: Mon Dec 26, 2005 3:53 pm    Post subject: Reply with quote

Yes, I know you can do that. BUT some software try to verify if there's something in /dev/cdrom. So, it would be interesting to have a /dev/virtualcdrom, mapped as a "real" device, not just a directory.
_________________
Life is a Sexually Transmitted Disease, with 100% mortality.
Back to top
View user's profile Send private message
mmbrothers
Apprentice
Apprentice


Joined: 24 Dec 2005
Posts: 224
Location: Boston

PostPosted: Mon Dec 26, 2005 4:32 pm    Post subject: Reply with quote

If you mount the iso as a loop device you can get the following:

Code:

mount -o loop /cdrom.iso /mnt/cdrom
mount
...
/cdrom.iso on /mnt/cdrom type iso9660 (rw,loop=/dev/loop0)


This lists that the device is /dev/loop0. You can even specify the loop device with the option loop=/dev/loopX You can then symlink from /dev/loopX to /dev/cdrom for the purposes of this program.
Back to top
View user's profile Send private message
datenwolf
n00b
n00b


Joined: 01 Sep 2003
Posts: 55

PostPosted: Sun Apr 09, 2006 3:19 pm    Post subject: Re: How to create a virtual cdrom device? Reply with quote

germanobax wrote:
I want to create a virtual device in /dev/ pretending to be a cdrom. Some programs try to look for /dev/cdrom, making impossible to just mount a ISO in some folder. I think it would be nice to have a way to map a image to a device and use it as some kind of virtual drive.

Can I do something like that?


Well, you could still make /dev/cdrom a link to a loopback device and assign the file to that.
Code:

mv /dev/cdrom /dev/hw_cdrom
losetup 0 $FILE
ln -s /dev/loop0 /dev/cdrom

The rest is as usual.
Back to top
View user's profile Send private message
PaulSorensen
Tux's lil' helper
Tux's lil' helper


Joined: 15 Apr 2004
Posts: 80
Location: Chicago, USA

PostPosted: Sun Apr 09, 2006 5:01 pm    Post subject: This might be useful for Wine Reply with quote

Another use-case for this is when using a windows program through wine that insists on seeing a CD inserted in the drive.

I'll give this a try, but it is important not just to see the device - it has to be able to query for a label - my guess is that the proposed loopback solution won't handle this, I'll let you know.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum