1. check if /proc/scsi/usb-storage-# exist or not
2. if exist. check if /proc/scsi/usb-storage-#/# exist or not
3. if exist. check the file /proc/scsi/usb-storage-#/# if it says Attach: Yes
4. if Yes. the # can be converted to device name:
0 = sda, 1=sdb, 2=sdc
5. But I don't know which USB port it connects to. and you don't need to know also.
for example: /proc/scsi/usb-storage-0/0 says Attach: No, then /dev/sda is not attached
/proc/scsi/usb-storage-1/1 says Attach: Yes, then it is attached, you can mount it.
If you plug in usb storage with brandname A first, the it is usb-storage-0, then you unplug it, but that directory still exists, and now you plug in Brandname B, the storage-1 directory will be created, and storage-0 is still there.
命令: lsusb
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 0a81:0101 Chesen Electronics Corp. Keyboard
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 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 003 Device 002: ID 093a:2510 Pixart Imaging, Inc. Hama Optical Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 148f:3370 Ralink Technology, Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
命令: lsusb
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 0a81:0101 Chesen Electronics Corp. Keyboard
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 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 003 Device 002: ID 093a:2510 Pixart Imaging, Inc. Hama Optical Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 148f:3370 Ralink Technology, Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub