# No /dev/sg0 with sata dvd player

## Fred Krogh

I can't write on dvd+rw disks, although reading commercial disks works fine.  I suspect that in addition to /dev/sr0, I should have a /dev/sg0,  If that is the case, how do I get that into /dev.  If not, what should I be looking for.  I have the following scsi references in /usr/src/linux/.config.

```
# SCSI device support

CONFIG_SCSI_MOD=y

CONFIG_SCSI=y

CONFIG_SCSI_DMA=y

# CONFIG_SCSI_NETLINK is not set

# CONFIG_SCSI_MQ_DEFAULT is not set

CONFIG_SCSI_PROC_FS=y

# SCSI support type (disk, tape, CD-ROM)

CONFIG_SCSI_CONSTANTS=y

# CONFIG_SCSI_LOGGING is not set

CONFIG_SCSI_SCAN_ASYNC=y

# SCSI Transports

# CONFIG_SCSI_SPI_ATTRS is not set

# CONFIG_SCSI_FC_ATTRS is not set

# CONFIG_SCSI_ISCSI_ATTRS is not set

# CONFIG_SCSI_SAS_ATTRS is not set

# CONFIG_SCSI_SAS_LIBSAS is not set

# CONFIG_SCSI_SRP_ATTRS is not set

# CONFIG_SCSI_LOWLEVEL is not set

# CONFIG_SCSI_DH is not set

# CONFIG_SCSI_OSD_INITIATOR is not set

# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may

# CONFIG_ISCSI_IBFT_FIND is not set

```

Many thanks,

Fred

----------

## NeddySeagoon

Fred Krogh,

I suspect its CONFIG_CHR_DEV_SG=y

----------

## Fred Krogh

I have CONFIG_CHR_DEV_SG=m, I can try changing that to a y, but will need to reboot to try it and that I can only do after clearing up some other things.  Will let you know if that makes a difference.  Thanks.

----------

## Fred Krogh

I have just rebooted with a DVD+RW disk in the drive that I can't do anything with.  So now I have CONFIG_CHR_DEV_SG=y, but still no /dev/sg0.  I also needed to add a softlink to get /dev/dvd pointing to /dev/sr0.  So I'm hoping for another suggestion.  Thanks.

----------

## NeddySeagoon

Fred Krogh,

As a test use mknod to add a few /dev/sg nodes.

sg0 is 

```
crw-r----- 1 root disk 21, 0 May 12  2013 /dev/sg0
```

but so thot permissions don't get in the way, make them 666

Every sd or sr should have an associated sg, so don't skimp on mknod for the test.

If its the dev nodes missing, you should have just made the missing nodes.

If the kernel code is correct underneath the node, it will work util the next reboot.

If the kernel code is still missing, making dev nodes won't help.

What does uname -a tell you?

crw-r----- looks wrong

crw-rw---- would be better.  Thats my static /dev in a mess.

----------

## Fred Krogh

Using mknod, I now have in /dev *Quote:*   

> crw-rw-rw- 1 root root 21, 0 Jan 28 06:48 /dev/sg0
> 
> brw-rw----+ 1 root cdrom 11, 0 Jan 28 06:59 /dev/sr0

 uname -a gives *Quote:*   

> Linux mon1 3.18.3-gentoo #1 SMP Sat Jan 17 12:56:01 PST 2015 x86_64 Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz GenuineIntel GNU/Linux

 .  I have tried formatting disks using *Quote:*   

> dvd+rw-format -f /dev/dvd
> 
> mkfs.ext2 -t ext2 /dev/dvd

 When trying to look at the contents of the disk, I get *Quote:*   

> mount: wrong fs type, bad option, bad superblock on /dev/sr0,
> 
>        missing codepage or helper program, or other error
> 
>        In some cases useful info is found in syslog - try
> ...

 dmesg|tail ssys *Quote:*   

> [57795.372974] cdrom: sr0: dirty DVD+RW media, "finalizing"
> 
> [57925.581737] traps: get-edid[6678] trap invalid opcode ip:7fd947d25f6f sp:7fff2cb1f580 error:0 in libx86.so.1[7fd947d1e000+20000]

 Is any of this helpful?  Thanks.

----------

## NeddySeagoon

Fred Krogh,

The kernel you are running was built on 

```
Sat Jan 17 12:56:01 PST 2015 
```

On Tue Jan 27, 2015, you said you rebooted into a kernel with CONFIG_CHR_DEV_SG=y set.

It looks like you are not running the kernel you think you are.

```
dvd+rw-format -f /dev/dvd

mkfs.ext2 -t ext2 /dev/dvd
```

that takes me back.  I seem to recall that you need to use dvd+rw media (CD-RW works too), the kernel packet writing patches and some specdal /dev nodes to make this work.

The packet writitng mailing list closed on 2011.10.26 12:59.  I still have my archive.

I will need to do some digging if you want help with this, its been a long time since I used packet writing.  Its very slow.

My optical writer was IDE.

----------

## Fred Krogh

You are correct.  Evidently I updated the config files, but did not recompile the kernel.  Damn.  I'll post more when I have the kernel redone.  Sorry.

----------

## Fred Krogh

Now on a reboot, I have /dev/sr0, /dev/sg0, /dev/sg1, and /dev/sg2.  I still can't format a dvd in such a way that I can look at it.  I still get:  cdrom: sr0: dirty DVD+RW media, "finalizing".  Sometime in the distant (say 3 years?) past, I think I had this working.  I've also tried to get this to work using fdisk, and mkfs.ext2 /dev/sr0.  This one complains that  *Quote:*   

> mke2fs 1.42.12 (29-Aug-2014)
> 
> Found a dos partition table in /dev/sr0
> 
> Proceed anyway? (y,n) y
> ...

 After this I still have the same errors in trying to access the dvd.

If it is not too much trouble for you, I'd be interested in getting this fixed.  But this is not my only means for doing backups.  Many thanks,  Fred

----------

## NeddySeagoon

Fred Krogh,

I always used UDF on dvd+rw.  You must use a filesystem with a 32k block size as thats the block size on the underlying media.  UDF is designed for this sort of thing.

I recall that with UDF, it would gather writes into 32k chunks to avoid 8 read/erase/write cycles ber physical block written.

I suspect that with other filesystems the kernel caching will help a lot.

I've not used packet writining like this since before April 2009, when this system was put together.

I'll put a little time into it this week but it will be the weekend before I can fix my old PC, which has a failed PSU.

----------

## Fred Krogh

I'm not familiar with UDF.  If it is just a matter of formatting the dvd to use it, I'm all for it.  If this is what you are suggesting   I'll do some looking into this.  (At the moment as you know -- many thanks -- I'm more concerned about the monitor problem.)

----------

## NeddySeagoon

Fred,

Read http://fy.chalmers.se/~appro/linux/DVD+RW/

Its old and mostly still correct, even though its written around the ide-scsi layer which nobody uses.

udftools is still in the tree.  You will need UDF support in the kernel.

You can practice with UDF in an empty file - no need to destroy any media. 

When it works, try

```
mkudffs --spartable=2 --media-type=cdrw /dev/scdN

mount -o rw,noatime /dev/scdN /mnt/cdrom
```

well, not exactly that. Read the mkudffs man page. Adapt the command to your media, and /dev/sr0.

There is one wrinkle that sticks in my mind.  UDF is read only backwards compatible. That means that older versions of UDF code can read newer versions of the filesystem. However they may not be able to write them.

I'm out of touch with the kernel UDF driver.

----------

