Without knowing the order of which drives are being inserted and which ports they are being inserted (by human eye), is there a way to tell where they are being inserted using linux commands? I need this to be able to create a web design showing placement of ports & status etc.
Yes you can.
lsusb will give you details at the
Device level and with
fdisk -l it is possible to view which 'USB drives' are mapped into what devices. You can also look at the
dmesg outputs to see the port in which your 'USB' has been plugged in. You may have to constantly checking the output.
>> 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
My external drive has been plugged in to my
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
In the above, my external drive is