pre*_*ise 8 usb devices root-filesystem
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
Run Code Online (Sandbox Code Playgroud)
( 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? )
正如 Gilles 在评论中指出的那样,这些设备/dev/bus/usb/XXX/YYY
遵循内核中的命名策略。XXX
是相当稳定的总线号,但YYY
每次枚举 USB 设备时(当设备刚刚插入或重置时)都会发生变化。这是无法更改的,您也不应该更改它。
如果您需要更改设备上的权限(例如,为了测试目的而使非特权用户空间 USB 驱动程序成为可能),那么您可以制定 udev 规则。udev
我用来控制权限以便adb
能够连接到设备的示例:
# /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"
Run Code Online (Sandbox Code Playgroud)