# udev and /dev/sg* problem?

## agent_jdh

Hi,

Just noticed cd burning with k3b as a normal user has stopped working, I figured it was maybe an upgrade to 2.6.11 kernel, but having poked around and done a bit of searching on the forums, I think it might be a udev issue.

k3b fails with the debugging output "/usr/bin/cdrecord: Permission denied. Cannot open '/dev/sg0'. Cannot open SCSI driver."

The devices /dev/sg0 and /dev/sg1 are owned by root but in the root group as well, whereas the other /dev/sg* nodes are in the group cdrw.  Obviously /dev/sg0 should be in cdrw for writing to work.

I should point out at this time that I've seen a lot of other threads regarding writing problems with permissions and k3b, however, the fix in those cases usually appears to be using scsi-emulation, which is no use to me because my cd writer is actually a real SCSI device attached to an Adaptec scsi card.  I guess this is not such a common configuration these days.

I've searched Gentoo bugzilla for udev bugs but don't see anything about /dev/sg*.  If I can confirm this is the problem, I'll file a bug.

So what's the best way to get udev to put /dev/sg0 and /dev/sg1 in the cdrw group at boot?

TIA

Jonathan

EDIT - Manually changing the permissions on /dev/sg0 allows me to burn cd's as a user, but the permissions don't survive a reboot.  I don't see any mention of /dev/sg* devices in the rules/permissions files in /etc/udev.

----------

## bassvandijk

 *agent_jdh wrote:*   

> ...So what's the best way to get udev to put /dev/sg0 and /dev/sg1 in the cdrw group at boot?...

 

In: /etc/udev/permissions.d/50-udev.permissions you can change device owner and permissions settings.

Also check out the Gentoo udev guide

----------

## agent_jdh

I've just realised I'm loading the scsi card driver as a module (explicit in /etc/modules.autoload.d/kernel-2.6) - so I don't actually know if this is a udev issue.

As for /etc/udev/permissions.d/50-udev.permissions, looking at that file I can see the syntax, but I'm not really sure where the generic scsi devices /dev/sg* would fit in - I suppose for me just treating /dev/sg* as an optical device, and using the cdrw group, would be OK but maybe that isn't the best all-round solution e.g. for non-optical devices that use the generic scsi driver (are there any? usb keys?)

I'll modify that file though and see how I get on.

I've actually filed a bug report on this one which might not have been the best idea at this time.

EDIT:

Adding the line

sg*:root:cdrw:660

Into that file (in the optical devices section) didn't help.  Maybe I need to use coldplug as well?

----------

## manny15

Here's what I did:

/etc/udev/rules.d/10-udev.rules

```

BUS="scsi", KERNEL="sg*", NAME="%k", GROUP="cdrw"

BUS="scsi", KERNEL="sr*", SYSFS{model}="CDRW9602EXT-B", NAME="%k", GROUP="cdrw" SYMLINK="cdrw cdroms/cdrw"

```

Of couse the second entry is for my external USB CDRW, but by using the GROUP option, I set the group to both /dev/sg0 and /dev/sr0 to cdrw. And I'm the in cdrw group, so not I can do a cdrecord -scanbus and it works.

/etc/udev/permissions.d/* is no longer used.

----------

## AlanR

 *manny15 wrote:*   

> Here's what I did:
> 
> /etc/udev/rules.d/10-udev.rules
> 
> ```
> ...

 

Thanks! This fixed the problem when my external writer stopped working yesterday, after not using it for a while.

-Alan

----------

