Re: Retrieving Serial Numbers of USB disks from Scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 02, 2011 at 12:49:36PM -0700, Perry Wagle wrote:
> >From a script, I need to retrieve, if possible, the serial number of
> each disk-like device on my embedded system running linux 2.6.31
> (yeah, I know, its not my choice).
> 
> I find it in (say) /proc/scsi/usb-storage/3, where 3 is the scsi # it
> got this time.
> 
> If I search on the web, they say its impossible to get the serial
> numbers of usb devices, but obviously, they are wrong.
> 
> Is there a right way to retrieve the serial number of, say, /dev/sdb,
> from the maze of twisty symlinks in /sys and /proc?  Or do I make one
> up and hope I thought of all the special cases?

Do you want the serial number of the disk, or the serial number of the
USB device itself (note, they aren't the same.)

For the disk serial number, I think you need to do a scsi command to the
device to get it.

For a usb serial number, wind your way backwards from the
/sys/dev/block/ symlink to get to the USB device in charge of that
device to get the serial number.

Hope this helps,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux