# SCSI CDRW Woes

## bdemore

I think I've exhausted all the threads regarding this and am not sure where to turn.  I'm trying to get a Yamaha SCSI CDRW to be recognized by Gnome Toaster which I emerged last night.  My fstab looks like this:

/dev/cdroms/cdrom0	/mnt/cdrw   	auto	noauto,ro,user		0 0

I can mount and read from it with no problem.  When I issue the command cdrecord -scanbus I get the following:

Cdrecord 1.11a39 (i686-pc-linux-gnu) Copyright (C) 1995-2002 Jörg Schilling

cdrecord: Device or resource busy. Cannot open '/dev/sg0'. Cannot open SCSI driver.

cdrecord: For possible targets try 'cdrecord -scanbus'. Make sure you are root.

cdrecord: For possible transport specifiers try 'cdrecord dev=help'.

The command dmesg gives me: 

Vendor: YAMAHA    Model: CRW8424S          Rev: 1.0j

  Type:   CD-ROM                             ANSI SCSI revision: 02

Attached scsi CD-ROM sr0 at scsi0, channel 0, id 5, lun 0

(scsi0:A:5): 20.000MB/s transfers (20.000MHz, offset 15)

sr0: scsi3-mmc drive: 24x/16x writer cd/rw xa/form2 cdda tray

Uniform CD-ROM driver Revision: 3.12

I have sg compiled into the kernel.  I've read quite a bit about permissions but I don't think that's my problem.  Any help would be appreciated.

----------

## BradN

have you tried it logged in as root?

----------

## bdemore

Yeah, same results

----------

## BradN

Hmm, I can't think of anything else offhand... I've only set up IDE CD burners through SCSI emulation.  I don't know if there's anything else that must be done for real SCSI burners.

----------

## ronmon

Maybe this will help. It's the relevant parts of my /etc/devfsd.conf:

This gives non-root users write permission

```
REGISTER        ^scsi/host0/bus0/target6/lun0/generic$  PERMISSIONS root.cdrw   660

REGISTER        ^cdr$                                   PERMISSIONS root.cdrw   660
```

And this creates a /dev/cdr link

```
LOOKUP          ^cdr$           CFUNCTION GLOBAL mksymlink cdroms/cdrom1 cdr

REGISTER        ^cdroms/cdrom1$ CFUNCTION GLOBAL mksymlink $devname cdr

UNREGISTER      ^cdroms/cdrom1$ CFUNCTION GLOBAL unlink cdr
```

It is slightly different than the examples that are in the stock devfsd.conf file. Take a look at those, compare the differences and experiment. I would leave the original examples commented out and copy new lines to test so that you will have them to refer to later. Your normal user has to be in the cdrw group for this to work. My scanner is set up the same way.

----------

## MBCook

Do you have the CD mounted when you try to write to it? Also, are you sure it's sg0? Does sg0 even exist?

----------

## bdemore

I don't even know what sg0 is.  I thought maybe it refered to the SCSI generic module which i've got loaded.

----------

## MBCook

Yes it does. Do you have one in /dev?

What the sgXs do is allow bypass any driver thats there (like the scsi-cdrom driver) and give a program total controll over the drive. This is needed for CD-R(W), tape drives?, scanners?, etc.

----------

## bdemore

It's there but it's a 0 byte file.  Maybe I need to change the permissions?  Should my fstab reflect a /dev/sg0?  I tried that but couldn't mount anything.

----------

## MBCook

It's fine that it's 0 bytes, there is nothing there. Is the drive mounted when you run cdrecord (or whatever)? Are you trying this with a CD in the drive? Sorry, but this is about as helpful as I can be. I've never used a CD writer under linux.

----------

## bdemore

I have no problem mounting the drive as a cdrom but can't as a cdrw (I guess).

----------

## nalin

 *MBCook wrote:*   

> Is the drive mounted when you run cdrecord (or whatever)

 

Im using scsi-emulation for my IDE burner but I am quite sure it does not need be mounted to burn (and I am pretty sure it wouldnt mount as iso9660 with the blank disk if one tried).

BDEmore, Do you have all of the following enabled in your kernel.  

From the CD-Writing howto...you should have

BLOCK 	loopback device			M

SCSI   	SCSI support                		Y/M    

SCSI   	SCSI CD-ROM support		Y/M     

SCSI   	Enable vendor-specific		Y      

SCSI   	SCSI generic support      		Y/M     

SCSI   	(select a low-level driver)      	Y

FS     	ISO 9660 CDROM filesystem   Y/M

FS     	Microsoft Joliet cdrom...		Y

...lotta info at tldp.org cd-writing howto so id check that out if you havent yet done so, figure out exactly where your problem lies and use the forums for additional support if necessary...

good luck

----------

## ronmon

For writing, the drive is identified by its SCSI address in the order of Channel, ID, Lun (0,6,0) in my case. You can see yours by doing 'cat /proc/scsi/scsi'.

That translates to /dev/scsi/host0/bus0/target6/lun0/generic in devfs parlance. If you take a close look at /dev/sg0 (sg2 in my case) you should find that it is a link to your device. I used a very explicit setup in my devfsd.conf example above that points directly to the device, assigned it permissions, and then linked it to a descriptive name (/dev/cdr) so I don't have to remember which sg* is which. I do the same for /dev/scanner and just the link for /dev/dvd.

I'm convinced that the solution to your problem lies in devfsd.conf. It took a while to get the hang of it, but once I did things just started working.

P.S. No, you don't mount it to write to it. In fact you can't because there is no file system yet.

----------

## bdemore

That's a lot of excellent descriptive help, thanks.  Ronmon, could you post your fstab and devfs.config so that I can understand how they relate?  Thanks again.

----------

## bdemore

OK, thanks to ronmon I think I've made a breakthrough.  sg0 points to my SCSI tape drive and sg1 points to my cdrw.  Now I just have to figure out how to tell the cd software to link my cdrw to sg1 instead of sg0.  I know it is done in devfsd.conf but i still don't know which line to change with the modification.

----------

## ronmon

Well, instead of cluttering up the thread with the entire files, how about the chunks that matter.

/etc/fstab (actually this does not matter because writing is done to the raw device)

```

/dev/cdroms/cdrom0  /dvd        iso9660     noauto,ro,users                     0 0

/dev/cdroms/cdrom1  /cdr        iso9660     noauto,ro,users                     0 0

/dev/floppy/0       /floppy     auto        rw,noauto,users,uid=1000,gid=100    0 0

```

/etc/devfsd.conf

```

REGISTER        ^scsi/host0/bus0/target5/lun0/generic$  PERMISSIONS root.cdrw   660

REGISTER        ^scanner$                               PERMISSIONS root.cdrw   660

REGISTER        ^scsi/host0/bus0/target6/lun0/generic$  PERMISSIONS root.cdrw   660

REGISTER        ^cdr$                                   PERMISSIONS root.cdrw   660

LOOKUP          ^dvd$           CFUNCTION GLOBAL mksymlink cdroms/cdrom0 dvd

REGISTER        ^cdroms/cdrom0$ CFUNCTION GLOBAL mksymlink $devname dvd

UNREGISTER      ^cdroms/cdrom0$ CFUNCTION GLOBAL unlink dvd

LOOKUP          ^cdr$           CFUNCTION GLOBAL mksymlink cdroms/cdrom1 cdr

REGISTER        ^cdroms/cdrom1$ CFUNCTION GLOBAL mksymlink $devname cdr

UNREGISTER      ^cdroms/cdrom1$ CFUNCTION GLOBAL unlink cdr

LOOKUP          ^scanner$ CFUNCTION GLOBAL mksymlink scsi/host0/bus0/target5/lun0/generic scanner

REGISTER        ^scsi/host0/bus0/target5/lun0/generic$  CFUNCTION GLOBAL mksymlink $devname scanner

UNREGISTER      ^scsi/host0/bus0/target5/lun0/generic$  CFUNCTION GLOBAL unlink scanner

```

Aargh, it's wrapping two lines in that last section. Hope you can figure it out.

----------

