在不知道插入哪个驱动器的顺序和插入哪个端口的情况下(通过人眼),是否有一种方法可以使用linux命令判断它们插入的位置?我需要这能够创建一个网页设计,显示位置的端口和状态等。
发布于 2019-01-30 05:50:56
是的你可以。lsusb将在Bus和Device级别向您提供详细信息,使用fdisk -l可以查看哪些“USB驱动器”映射到哪些设备中。您还可以查看dmesg输出,查看插入“USB”的端口。您可能必须不断检查输出。
例如:
>> lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 04f2:b2db Chicony Electronics Co., Ltd
Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]
Bus 001 Device 003: ID 147e:2020 Upek TouchChip Fingerprint Coprocessor (WBF advanced mode)
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 1058:07a8 Western Digital Technologies, Inc. My Passport (WDBBEP), My Passport for Mac (WDBLUZ)
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub我的外部驱动器已插入到我的USB3.0端口。
Device Start End Sectors Size Type
/dev/sda1 2048 411647 409600 200M BIOS boot
/dev/sda2 411648 126240767 125829120 60G Linux root (x86-64)
/dev/sda3 126240768 143017983 16777216 8G Linux swap
/dev/sda4 143017984 976773127 833755144 397.6G Linux root (x86-64)
Disk /dev/sdb: 931.5 GiB, 1000170586112 bytes, 1953458176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00023f15
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1953458175 1953456128 931.5G 7 HPFS/NTFS/exFAT在上面,我的外部驱动器是/dev/sdb1。
https://unix.stackexchange.com/questions/497607
复制相似问题