nel*_*aro 8 linux usb mtp udev usb-storage
我有一个不是安卓/移动设备的特定设备的问题。
这是一个带有内部硬盘驱动器的媒体播放器,我试图将其连接为大容量存储设备,以便我也可以从中复制电影/连续剧。
当我将它连接到我的系统时,我看到以下内容
kernel: usb 1-4: new high-speed USB device number 7 using xhci_hcd
systemd[1]: Starting Cleanup of Temporary Directories...
systemd[1]: Started Cleanup of Temporary Directories.
mtp-probe[4978]: checking bus 1, device 7: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4"
kernel: usb 1-4: can't set config #1, error -110
mtp-probe[4978]: bus: 1, device: 7 was not an MTP device
kernel: usb 1-4: USB disconnect, device number 7
Run Code Online (Sandbox Code Playgroud)
lsusb 显示我
Bus 001 Device 008: ID 174c:5106 ASMedia Technology Inc. ASM1051 SATA 3Gb/s bridge
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x174c ASMedia Technology Inc.
idProduct 0x5106 ASM1051 SATA 3Gb/s bridge
bcdDevice 0.01
iManufacturer 2
iProduct 3
iSerial 1
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Run Code Online (Sandbox Code Playgroud)
我的内核和发行版
uname -a
Linux aaron-pc 4.9.24-1-MANJARO #1 SMP PREEMPT Fri Apr 21 08:32:28 UTC 2017 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
经过大量阅读和测试。
我发现这与默认 Udev 规则的最近更改有关,如果它们与 USB 设备的任何其他 udev 规则不匹配,则为由 MTP 处理的设备设置一个包罗万象的规则。
而不是像以前那样将我的设备安装为 USB 大容量存储设备。
我发现我需要让 udev 知道这个设备应该被管理一个 USB 大容量存储设备而不是 MTP 捕获所有规则
首先,我需要我的设备 ID。下面是列表中的最后一个
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2a Intel Corp.
Bus 001 Device 002: ID 04f2:b51d Chicony Electronics Co., Ltd
Bus 001 Device 006: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)
Bus 001 Device 005: ID 0b05:181b ASUSTek Computer, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 007: ID 174c:5106 ASMedia Technology Inc
Run Code Online (Sandbox Code Playgroud)
我确信这比我在这里拥有的更多,但这对我有用。我获取设备 ID,174c:5106并在下面的 udev 规则中替换它。
$ cat /etc/udev/rules.d/90-myrules.rules
SUBSYSTEMS=="usb", ENV{MODALIAS}=="usb:174c:5106", ENV{MODALIAS}="usb-storage"
Run Code Online (Sandbox Code Playgroud)
我现在在系统日志中看到以下内容
journalctl -fe
kernel: usb 1-2: USB disconnect, device number 9
kernel: usb 1-2: new high-speed USB device number 10 using xhci_hcd
mtp-probe[9850]: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
mtp-probe[9850]: bus: 1, device: 10 was not an MTP device
kernel: usb-storage 1-2:1.0: USB Mass Storage device detected
kernel: scsi host3: usb-storage 1-2:1.0
kernel: usbcore: registered new interface driver usb-storage
kernel: usbcore: registered new interface driver uas
kernel: scsi 3:0:0:0: Direct-Access ST310005 24AS JC4B PQ: 0 ANSI: 0
kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0
kernel: sd 3:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
kernel: sd 3:0:0:0: [sdb] Write Protect is off
kernel: sd 3:0:0:0: [sdb] Mode Sense: 23 00 00 00
kernel: sd 3:0:0:0: [sdb] No Caching mode page found
kernel: sd 3:0:0:0: [sdb] Assuming drive cache: write through
kernel: sdb: sdb1
kernel: sd 3:0:0:0: [sdb] Attached SCSI disk
Run Code Online (Sandbox Code Playgroud)
首先将文件复制/lib/udev/rules.d/69-libmtp.rules到/etc/udev/rules.d/69-libmtp.rules:
$ sudo cp /lib/udev/rules.d/69-libmtp.rules /etc/udev/rules.d/69-libmtp.rules
Run Code Online (Sandbox Code Playgroud)
在此文件的顶部,您可以找到:
# Some sensitive devices we surely don't wanna probe
ATTR{idVendor}=="0670", GOTO="libmtp_rules_end"
ATTR{idVendor}=="0471", ATTR{idProduct}=="083f", GOTO="libmtp_rules_end"
Run Code Online (Sandbox Code Playgroud)
mtp-probe然后通过在上述行之后添加下一行来排除该设备:
ATTR{idVendor}=="093a", ATTR{idProduct}=="2516", GOTO="libmtp_rules_end"
Run Code Online (Sandbox Code Playgroud)
我使用lsusbshell 命令找到了我的 USB 设备 ID。这是093a:2516
| 归档时间: |
|
| 查看次数: |
29882 次 |
| 最近记录: |