Suppose in a linux machine you have both SATA and USB devices present, and if they are all detected properly, how do you know whether a specific device(sda1/ sdb1) is USB device OR SATA device. Note: devices needs to be manually mounted. Note: dmesg is cleared already. we cannot use /var/log/messages as that too is cleared.

Question is : Is there other way, say from /proc or any other command by which we know that the specific device(sda1/sdb1) is SATA OR USB ?

Thanks!

link|improve this question

29% accept rate
feedback

1 Answer

You can get that information from /sys virtual file system.

Run find /sys -name \*sd[ab]\*. Some of the lines from my station are:

/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/host69/target69:0:0/69:0:0:0/block/sdb
/sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda

There is "usb" in the line with sdb, there's none in the line with sda, so the USB drive is sdb.

Another piece of information that you can get is from

cat /sys/class/block/sda/removable
cat /sys/class/block/sdb/removable

files. If file's contents is 0, then the device isn't removable, so it cannot be an external USB drive. Some SATA drives report themselves as removable, so it may not be definitive.

link|improve this answer
Thanks! Also I find this useful: /dev/disk/by-id/XXX-usb . Here XXX-USB links to the device(sda/sdb) – kumar May 18 '11 at 15:49
It is under /proc directory – kumar May 18 '11 at 15:54
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.