# help: device only found if plugged in at udevstart [Solved?]

## yther

OK, I have read several guides on writing udev rules, and the udev man page.  At first I thought my rule was working, as I would run udevstart and my device would show up in /dev, just as expected.  Then, after writing rules for my camera and Jump drive, I tried plugging them in.  My custom device does not appear in /dev unless the USB device is plugged in when udevstart runs!  Instead, /dev/sda1 is created, just as if I had no rule.

Here is my 10-local.rules:

```
SYSFS{vendor}=="OLYMPUS ", SYSFS{model}=="C7070WZ         ", KERNEL=="sda?", NAME="camOlympus"

SYSFS{vendor}=="LEXAR*", SYSFS{model}=="JUMPDRIVE*", KERNEL=="sda?", NAME="jumpdrive"
```

Here is the relevant info for my Jump drive, as revealed by udevinfo:

```
device '/sys/block/sda/sda1' has major:minor 8:1

  looking at class device '/sys/block/sda/sda1':

    KERNEL=="sda1"

    SUBSYSTEM=="block"

    SYSFS{dev}=="8:1"

    SYSFS{size}=="506848"

    SYSFS{start}=="32"

    SYSFS{stat}=="      13      104        0        0"

follow the "device"-link to the physical device:

  looking at the device chain at '/sys/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0/host4/target4:0:0/4:0:0:0':

    BUS==""

    ID=="4:0:0:0"

    DRIVER=="sd"

    SYSFS{detach_state}=="0"

    SYSFS{device_blocked}=="0"

    SYSFS{max_sectors}=="240"

    SYSFS{model}=="JUMPDRIVE SPORT "

    SYSFS{queue_depth}=="1"

    SYSFS{queue_type}=="none"

    SYSFS{rev}=="1000"

    SYSFS{scsi_level}=="3"

    SYSFS{state}=="running"

    SYSFS{timeout}=="30"

    SYSFS{type}=="0"

    SYSFS{vendor}=="LEXAR   "
```

Note that BUS shows up empty for some reason, but the rule still seems to work (if it's plugged in at udevstart).  I tried adding BUS=="" to my rule and it makes no difference.

```
udev 079-r1

baselayout 1.11.14-r3

hotplug 20040923-r1

(I'm NOT using HAL)

kernel 2.6.11-hardened-r15

        ^^ I know it's a bit old, but it's the latest stable according to Portage!
```

Any ideas?

EDIT:  Oh yeah, in case it is useful—this box is a PPC, G4.Last edited by yther on Mon Mar 06, 2006 4:45 am; edited 2 times in total

----------

## Headrush

Are than any messages in dmesg when either device is plugged in?

----------

## yther

 *Headrush wrote:*   

> Are than any messages in dmesg when either device is plugged in?

 

Lots.

```
grep -v grsec /var/log/kernel/current

### The Jump Drive ###

Feb 12 19:38:04 [kernel] usb 1-1.3: new full speed USB device using ohci_hcd and address 15

Feb 12 19:38:04 [kernel] scsi10 : SCSI emulation for USB Mass Storage devices

Feb 12 19:38:04 [kernel] usb-storage: device found at 15

Feb 12 19:38:09 [kernel]   Vendor: LEXAR     Model: JUMPDRIVE SPORT   Rev: 1000

Feb 12 19:38:09 [kernel] SCSI device sda: 506880 512-byte hdwr sectors (260 MB)

Feb 12 19:38:09 [kernel] SCSI device sda: 506880 512-byte hdwr sectors (260 MB)

Feb 12 19:38:09 [kernel] Attached scsi removable disk sda at scsi10, channel 0, id 0, lun 0

Feb 12 19:38:09 [kernel] Attached scsi generic sg0 at scsi10, channel 0, id 0, lun 0,  type 0

Feb 12 19:38:09 [kernel] usb-storage: device scan complete

### The Camera ###

Feb 12 20:10:46 [kernel] usb 1-1.3: new full speed USB device using ohci_hcd and address 18

Feb 12 20:10:46 [kernel] scsi13 : SCSI emulation for USB Mass Storage devices

Feb 12 20:10:46 [kernel] usb-storage: device found at 18

Feb 12 20:10:51 [kernel] SCSI device sda: 251904 512-byte hdwr sectors (129 MB)

Feb 12 20:10:51 [kernel] SCSI device sda: 251904 512-byte hdwr sectors (129 MB)

Feb 12 20:10:51 [kernel] Attached scsi removable disk sda at scsi13, channel 0, id 0, lun 0

Feb 12 20:10:51 [kernel] Attached scsi generic sg0 at scsi13, channel 0, id 0, lun 0,  type 0

Feb 12 20:10:51 [kernel] usb-storage: device scan complete
```

Remember, the devices work fine when they are plugged in.  I just want to be able to have unique entries for each one in /dev so that if I ever have my camera, Jump drive, and the ¡$&*#(@!™ USB floppy drive plugged in all at once there will be no confusion about which is which.   :Smile: 

----------

## Headrush

I want to know if there is info if they are plugged in after the system is started.

Please post output of lsusb also.

----------

## yther

All right, here we go!  This is just for the Jump drive, not the whole USB system.

```
nenene ~ # lsusb -vv -s 1:019

Bus 001 Device 019: ID 05dc:a410

Device Descriptor:

  bLength                18

  bDescriptorType         1

  bcdUSB               0.02

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0

  bDeviceProtocol         0

  bMaxPacketSize0        64

  idVendor           0x05dc

  idProduct          0xa410

  bcdDevice            0.30

  iManufacturer           1 LEXAR MEDIA

  iProduct                2 JUMPDRIVE SPORT

  iSerial                 3 1069A711224444071104

  bNumConfigurations      1

  Configuration Descriptor:

    bLength                 9

    bDescriptorType         2

    wTotalLength           32

    bNumInterfaces          1

    bConfigurationValue     1

    iConfiguration          0

    bmAttributes         0x80

    MaxPower              100mA

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass         8 Mass Storage

      bInterfaceSubClass      6 SCSI

      bInterfaceProtocol     80 Bulk (Zip)

      iInterface              0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x81  EP 1 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               none

        wMaxPacketSize         64

        bInterval             255

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x02  EP 2 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               none

        wMaxPacketSize         64

        bInterval             255

  Language IDs: (length=4)

     0409 English(US)

Bus 001 Device 001: ID 0000:0000

Device Descriptor:

  bLength                18

  bDescriptorType         1

  bcdUSB              10.01

  bDeviceClass            9 Hub

  bDeviceSubClass         0 Unused

  bDeviceProtocol         0

  bMaxPacketSize0         8

  idVendor           0x0000

  idProduct          0x0000

  bcdDevice            6.02

  iManufacturer           3 Linux 2.6.11-hardened-r15 ohci_hcd

  iProduct                2 Apple Computer Inc. KeyLargo USB

  iSerial                 1 0001:11:08.0

  bNumConfigurations      1

  Configuration Descriptor:

    bLength                 9

    bDescriptorType         2

    wTotalLength           25

    bNumInterfaces          1

    bConfigurationValue     1

    iConfiguration          0

    bmAttributes         0xc0

      Self Powered

    MaxPower                0mA

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           1

      bInterfaceClass         9 Hub

      bInterfaceSubClass      0 Unused

      bInterfaceProtocol      0

      iInterface              0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x81  EP 1 IN

        bmAttributes            3

          Transfer Type            Interrupt

          Synch Type               none

        wMaxPacketSize          2

        bInterval             255

  Language IDs: (length=4)

     0409 English(US)
```

----------

## Headrush

I just needed lsusb, not all that detailed info, but it works anyways.

Use these as your SYSFS attributes:

```
  idVendor           0x05dc 

  idProduct          0xa410 
```

eg

```
BUS="usb", SYSFS{idVendor}="0x05dc", SYSFS{idProduct}="0xa410", NAME="%k", SYMLINK="jumpdrive%n"
```

If your jumpdrive has 1 partition, you should be able to access it as /dev/jumpdrive1 no matter which sdX device it is.

----------

## yther

 *Headrush wrote:*   

> I just needed lsusb, not all that detailed info, but it works anyways.

 

I figured the more info, the better, so folks wouldn't have to ask for more later.   :Smile: 

That rule does not work.  I also tried removing the BUS part, and that doesn't work either.   :Sad: 

/dev/sda and /dev/sda1 are created, as well as /dev/sg0, but no /dev/jumpdriveX at all.

Interestingly, when I try the same rule on the Intel box in the next room, I get the same results.  That machine is running kernel 2.6.14-hardened-r5 and the same versions of baselayout and udev.  At least that tells me it's not a PPC-specific problem, and it's not limited to one version of the kernel!

I was not using idVendor or idProduct in my rules, because they did not show up in udevinfo.  Therefore I thought udev would not be able to use that information to identify the devices.

BTW, I do appreciate your taking the time to work with me here!

----------

## Headrush

Which file are you putting the custom rules in?

Maybe turn on logging in /etc/udev/udev.conf and restart udev.

```
udev_log="yes"
```

----------

## yther

 *Headrush wrote:*   

> Which file are you putting the custom rules in?

 

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

Also, I've enabled logging and run udevstart, but this is all I see in the logs when I plug in my Jump drive:

```
Feb 13 21:50:36 [kernel] usb 1-1.3: new full speed USB device using ohci_hcd and address 23

Feb 13 21:50:36 [kernel] scsi18 : SCSI emulation for USB Mass Storage devices

Feb 13 21:50:41 [kernel] SCSI device sda: 506880 512-byte hdwr sectors (260 MB)

Feb 13 21:50:41 [kernel] SCSI device sda: 506880 512-byte hdwr sectors (260 MB)

Feb 13 21:50:41 [kernel] Attached scsi removable disk sda at scsi18, channel 0, id 0, lun 0

Feb 13 21:50:48 [scsi.agent] disk at /devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0/host18/target18:0:0/18:0:0:0
```

I just now noticed a program called udevmonitor.  When I run that and plug in my drive, the following prints:

```
UEVENT[1139885855.168394] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3

UEVENT[1139885855.170568] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0

UEVENT[1139885855.188578] add@/class/scsi_host/host19

UDEV  [1139885858.547017] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3

UEVENT[1139885860.194928] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0/host19/target19:0:0/19:0:0:0

UEVENT[1139885860.219963] add@/block/sda

UEVENT[1139885860.348612] add@/block/sda/sda1

UEVENT[1139885860.349501] add@/class/scsi_device/19:0:0:0

UEVENT[1139885860.355255] add@/class/scsi_generic/sg0

UDEV  [1139885863.568430] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0

UDEV  [1139885863.625347] add@/class/scsi_host/host19

UDEV  [1139885866.998878] add@/devices/pci0001:10/0001:10:0d.0/0001:11:08.0/usb1/1-1/1-1.3/1-1.3:1.0/host19/target19:0:0/19:0:0:0

UDEV  [1139885867.133641] add@/class/scsi_device/19:0:0:0

UDEV  [1139885867.181874] add@/class/scsi_generic/sg0

UDEV  [1139885867.249256] add@/block/sda

UDEV  [1139885867.493802] add@/block/sda/sda1
```

Is that helpful?

----------

## Headrush

What is the output of

```
ls -l /etc/udev/rules.d/
```

Maybe somehow there is an earlier rule that is read before this once and hence it is not used.

----------

## yther

Hm.  There is a file called 05-udev-early.rules.  It contains:

```
# sysfs is populated after the event is sent

ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus"

ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"

# ignore these events until someone needs them

SUBSYSTEM=="drivers",           OPTIONS="ignore_device"

SUBSYSTEM=="module",            OPTIONS="ignore_device"
```

dep says this file belongs to the udev package.

----------

## yther

...I have now upgraded to kernel version 2.6.14-hardened-r5, and (mysteriously) the udev rules seem to work as expected.  That means, I just plugged in my camera and /dev/camOlympus appeared.  It mounts as I would expect it to, and normal users can mount it as well.

I'm not quite sure what happened, but if it continues to work I'll be satisfied.

----------

