Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I noticed that every time I connect a USB device, a new device gets created in the /dev/bus/usb/001/ directory. Further on each reconnection of the same device, the "Device Number" and "ID" change.

So, I'd like to know how the creation of new device file (in /dev/bus/usb/001/) work? Can I control the behaviour, say limit the device number to 002, by making changes in some configuration file (if any)?

Here's a the output for reference:

$ ls /dev/bus/usb/001
001  002
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0781:5406 SanDisk Corp. Cruzer Micro U3
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 08ec:0015 M-Systems Flash Disk Pioneers Kingston DataTraveler ELITE
$ lsusb 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 008: ID 0781:5406 SanDisk Corp. Cruzer Micro U3
$ ls /dev/bus/usb/001/
001  008

( Also I don't know why Kingston Flash Disk was shown in the output. I don't have a Kingston device!... Maybe it's just a glitch, or is it? )

Another contextual topic of interest:

share|improve this question
2  
start with reading man udev –  Alex P. Jan 11 at 17:46
1  
Why are you concerned about the number? The numbers in /dev follows the numbers used by the kernel. Do you want to change the numbers inside the kernel (why?) (in which case udev is irrelevant, @Alex), or do you want to get a stable path under /dev (in which case forget about changing the numbers and use udev instead). –  Gilles Jan 11 at 21:46
    
..a stable path sounds good (and doesn't that have anything to do with the bus and device number files?).. I don't know much about these.. so answer with insights on both the topics would make a good reference.. –  rusty Jan 12 at 6:06

1 Answer 1

The devices in /dev/bus/usb/XXX/YYY follow naming policies in the kernel as noted Gilles in the comments. XXX is the bus number which is quite stable, but YYY changes every time the USB device gets enumerated (when a device just got inserted or reset). This cannot be changed and you shouldn't have to change this either.

If you need to change permissions on the device (for example, to make an unprivileged userspace USB driver possible for testing purposes), then you could make a udev rule. An example where I use udev to control the permissions such that adb is able to connect to the device:

# /etc/udev/rules.d/42-usb-permissions.rules
SUBSYSTEM!="usb", GOTO="end_skip_usb"

# CWM 6.0.4.3 in recovery mode
ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="d001", GROUP="peter"

# CM 10.2 with MTP disabled
ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="d002", GROUP="peter"

ATTRS{idVendor}=="148f", ATTRS{idProduct}=="5372", GROUP="peter"

LABEL="end_skip_usb"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.