Ubuntu: How do I list all storage devices (thumb drives/external hard drives) that are connected via USB, from the command line? [duplicate]



Question:

Possible Duplicate:
How to detect an USB device?

I would like to list ONLY devices connected via usb.

The problem is that Ubuntu seems to see all thumb drives as removable (in /sys/block/*/removable), but it does not see external hard drives the same way.


Solution:1

If you are looking for the mounted disks, a simple

df  

will list them along with all your other disks along with some useful info.


Solution:2

I'd recommend checking the udev properties of the devices, specifically the ID_BUS property:

for device in /sys/block/*  do      if udevadm info --query=property --path=$device | grep -q ^ID_BUS=usb      then          echo $device      fi  done  


Solution:3

I think

lsusb  

will give you what you want, at least if I understand what you're asking. (Of course, it lists all usb devices, not just storage.)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »