[CentOS] Detect if a drive is USB?

Lists lists at benjamindsmith.com
Fri Sep 21 14:36:05 EDT 2012


I'm updating a script to work with EL6 (previously worked on EL5) and am 
stumped, google fu is failing me. Part of the script is to detect USB 
drives and mount them. Previously, It worked something like

isUsbDevice() {
if [ -f /sys/block/$1/usb ] ; then
  // do stuff
  fi;
}

but I don't find the "usb" file/directory anywhere to be found any more 
on el6. I've tried the output of lsusb and lsusb -v but in no case have 
I been able to find anything there matching anything in /sys/block that 
matching anything in lsusb's output.

Given an available drive (EG: /dev/sdk) how can I reliably tell it's 
interface type? (USB/SATA/PATA/SCSI ?)




More information about the CentOS mailing list