linux下如何辨认多个存储设备
我现在起来一个板子,下面的存储设备有硬盘阵列,还有USB和SD卡。
已知硬盘在 /dev/cciss/下有c0d0 c0d0p1 c0d0p2
/dev/下还有sda sda1 sdb sdb1 sdb2
现在的问题是如何区分sda是USB还是SD卡。
板子是通过服务器ssh远程登录的,所以不能通过简单的插拔来辨别:wink:
请高手帮忙解答一下,多谢了!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
dmesg | grep usb
dmesg | grep sd 似乎也没有什么帮助。
如果你的读卡器是usb读卡器,可以用lsusb命令查看一下
root@fleya-laptop:/tmp# lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 069: ID 045e:00a4 Microsoft Corp.
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 001 Device 096: ID 058f:6335 Alcor Micro Corp. SD/MMC Card Reader
Bus 001 Device 003: ID 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC WebCam / CNF7129
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 0b05:b700 ASUSTek Computer, Inc. Broadcom Bluetooth 2.1
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
sd卡Device 096
dmesg > /tmp/a
在/tmp/a文件中搜索found at 96
[97280.788833] usb-storage: device found at 96
[97280.788840] usb-storage: waiting for device to settle before scanning
[97285.791894] usb-storage: device scan complete
[97285.792606] scsi 11:0:0:0: Direct-Access Single Flash Reader 1.00 PQ: 0 ANSI: 0
[97285.794000] sd 11:0:0:0: Attached scsi generic sg1 type 0
[97286.270343] sd 11:0:0:0: [sdb] 7861248 512-byte logical blocks: (4.02 GB/3.74 GiB)
[97286.277514] sd 11:0:0:0: [sdb] Write Protect is off
[97286.277528] sd 11:0:0:0: [sdb] Mode Sense: 03 00 00 00
[97286.277536] sd 11:0:0:0: [sdb] Assuming drive cache: write through
[97286.302378] sd 11:0:0:0: [sdb] Assuming drive cache: write through
[97286.302399] sdb: sdb1
[97286.327111] sd 11:0:0:0: [sdb] Assuming drive cache: write through
[97286.327129] sd 11:0:0:0: [sdb] Attached SCSI removable disk
由上信息可知sd卡是sdb
1 .lsusb
root@hp:/tmp> lsusb
Bus 006 Device 003: ID 03f0:1327 Hewlett-Packard
Bus 006 Device 002: ID 03f0:1027 Hewlett-Packard
Bus 006 Device 001: ID 1d6b:0001
Bus 001 Device 003: ID 058f:6387 Alcor Micro Corp. Transcend JetFlash 110 USB 2.0 Flash Drive (2GB)
Bus 001 Device 002: ID 058f:6335 Alcor Micro Corp.
Bus 001 Device 001: ID 1d6b:0002
Bus 005 Device 001: ID 1d6b:0001
Bus 004 Device 001: ID 1d6b:0001
Bus 003 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0001
没看到 SD卡的device号96 根据你的提示,由这个似乎应该在/tmp/a 下/found at 3 或者/found at 2
Bus 001 Device 003: ID 058f:6387 Alcor Micro Corp. Transcend JetFlash 110 USB 2.0 Flash Drive (2GB)
Bus 001 Device 002: ID 058f:6335 Alcor Micro Corp.
2.dmesg > /tmp/a; vi /tmp/a
查找found at 3 或者 found at 2
usb usb6: configuration #1 chosen from 1 choice
hub 6-0:1.0: USB hub found
hub 6-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
usb 6-1: new full speed USB device using uhci_hcd and address 2
usb 6-1: configuration #1 chosen from 1 choice
usb 6-2: new full speed USB device using uhci_hcd and address 3
usb 6-2: configuration #1 chosen from 1 choice
hub 6-2:1.0: USB hub found
hub 6-2:1.0: 7 ports detected
似乎没有看出来SD卡是哪个
3.还是在/tmp/a下查找 sd
scsi 0:0:0:0: Direct-Access Single Flash Reader 1.00 PQ: 0 ANSI: 0
scsi 1:0:0:0: Direct-Access JetFlash TS1GJFV30 8.07 PQ: 0 ANSI: 2
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 1:0:0:0: [sdb] Assuming drive cache: write through
sd 1:0:0:0: [sdb] 2002944 512-byte hardware sectors (1026 MB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 1:0:0:0: [sdb] Assuming drive cache: write through
sdb: sdb1 sdb2
sd 1:0:0:0: [sdb] Attached SCSI removable disk
usb-storage: device scan complete
sd 0:0:0:0: [sda] 3962880 512-byte hardware sectors (2029 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 3962880 512-byte hardware sectors (2029 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk
usb-storage: device scan complete
没有像你提示的那样找出SD卡是sdb
但是根据 Bus 001 Device 003: ID 058f:6387 Alcor Micro Corp. Transcend JetFlash 110 USB 2.0 Flash Drive (2GB)
和 sd 1:0:0:0: [sdb] 2002944 512-byte hardware sectors (1026 MB)
由其容量为2G似乎可以确定SD是sdb,不知是否准确。
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
scsi0 是模拟的device 2 设备
scsi1 是模拟的device 3 设备 (sd卡)
scsi 0:0:0:0: Direct-Access Single Flash Reader 1.00 PQ: 0 ANSI: 0 (scsi0)
scsi 1:0:0:0: Direct-Access JetFlash TS1GJFV30 8.07 PQ: 0 ANSI: 2 (scsi1)
sdb: sdb1 sdb2
sd 1:0:0:0: [sdb] Attached SCSI removable disk
(sdb 是scsi1 设备)也就是sd卡 ,只不过信息输出顺序不一致:)
多谢fleya的解答!