Answering my own message for posterity's sake: This line will output
"E:
ID_BUS=usb" for any block
device connected to a USB bus:
udevadm info --query=all --name=$file 2>/dev/null | grep -i BUS=usb;
The basic idea is to
1) use udevadm to get all info on device $file (where $file is a string
like "sde")
a) send all errors to /dev/null.
2) grep the output of udevadm for the string "BUS=usb" which appears
on
USB devices.
Note that you must have $file defined with a device name which I got by
listing the contents of /sys/block.
Good luck! Also, if anybody has a better solution, please reply. The
above appeared to be "good enough"
to finish porting my admin script.
-Ben
On 09/21/2012 11:36 AM, Lists wrote:> 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 ?)
>
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>