Linux 如何确定连接的USB设备是否为USB闪存驱动器?
如何确定已将何种介质连接到系统 我有Ubuntu,当我插入一张SD卡时,它注意到它实际上是一张SD卡。U盘的计数相同 但我如何在低级别上确定何时插入新设备,它是什么类型的 似乎根本找不到这方面的信息 编辑:更完整一点:我说它是Linux环境,但实际上它是嵌入式环境中的Android。我将其标记为Linux,因为我确实在尝试从命令行进行检查 udevadm命令不可用,并且lsusb-vv显示:Linux 如何确定连接的USB设备是否为USB闪存驱动器?,linux,linux-kernel,linux-device-driver,usb-flash-drive,Linux,Linux Kernel,Linux Device Driver,Usb Flash Drive,如何确定已将何种介质连接到系统 我有Ubuntu,当我插入一张SD卡时,它注意到它实际上是一张SD卡。U盘的计数相同 但我如何在低级别上确定何时插入新设备,它是什么类型的 似乎根本找不到这方面的信息 编辑:更完整一点:我说它是Linux环境,但实际上它是嵌入式环境中的Android。我将其标记为Linux,因为我确实在尝试从命令行进行检查 udevadm命令不可用,并且lsusb-vv显示: Bus 001 Device 001: ID 1d6b:0002 Bus 001 Device 002:
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 0424:2640
Bus 001 Device 003: ID 0424:4040
Bus 002 Device 001: ID 1d6b:0001
这是非常少的信息。lsusb命令列出了系统中注册的USB设备。 有关更多详细信息,请尝试
lsusb-vv
。您可以使用-s
标志以特定设备为目标
更新:
这取决于您帐户的权限,某些详细信息需要更高的权限。例如,下面是我的鼠标的输出:
Bus 003 Device 003: ID 04f3:0230 Elan Microelectronics Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x04f3 Elan Microelectronics Corp.
idProduct 0x0230
bcdDevice 24.58
iManufacturer 0
iProduct 2 USB+PS/2 Optical Mouse
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 2 Mouse
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 52
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0004 1x 4 bytes
bInterval 10
Device Status: 0x0000
运行这样的命令可能很有用:
$ udevadm info -a -p $(udevadm info -q path -n /dev/sdX)
输出可能如下所示:
[...]
looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5':
KERNELS=="1-1.5"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="80"
ATTRS{bMaxPower}=="200mA"
ATTRS{urbnum}=="6519"
ATTRS{idVendor}=="13fe"
ATTRS{idProduct}=="1d00"
ATTRS{bcdDevice}=="0100"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="480"
ATTRS{busnum}=="1"
ATTRS{devnum}=="3"
ATTRS{devpath}=="1.5"
ATTRS{version}==" 2.00"
ATTRS{maxchild}=="0"
ATTRS{quirks}=="0x0"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Kingston"
ATTRS{product}=="DataTraveler 2.0"
ATTRS{serial}=="5B7A08A1010F"
[...]
您可以看到一些描述设备的属性
如何确定USB设备是否为U盘
国家自然资源委员会。USB设备通常不宣传其形状。想想:
- 棒式CDROM设备——通常以移动连接设备的形式提供自己的windows驱动程序
- 用于无线键盘/鼠标/HIDs/etc或音频插孔的支杆
- 那个胖乎乎的MP3播放器挡住了附近所有的USB端口
ID\u USB\u DRIVER=USB storage
,udevadm info path-n/dev/sda
,它们显然是在寻找闪存驱动器(通常称为棒),而不是物理外壳。