Here is my experience of getting USB Storage device serial on Linux:
USB is a SCSI device. As per USB specification USB devices have
ProductID, VendorID and Serial. (Some Local pen drives may not have this serial). Serial of the USB device is unique and never change even you format the storage device.
In Linux you can get this information very easily by following ways:
# cat /proc/bus/usb/devices
You will get listing of all the USB devices something like this:
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=058f ProdID=6387 Rev= 1.41
S: Product=Mass Storage Device
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Notice the 6th line containing "SerialNumber=WVIAZIUI"
# ls /proc/scsi/usb-storage
You will get name of the directories containing usb information for each usb storage device like:
# cat /proc/scsi/usb-storage/4
You will get output like this:
Host scsi4: usb-storage
Product: Mass Storage Device
Serial Number: WVIAZIUI
Protocol: Transparent SCSI
Notice the 4th line containing "Serial Number: WVIAZIUI"
As you can see it is very easy to get USB storage device serial in Linux but if you have more than one USB storage devices (Pen Drives) inserted in the system then
how to identify the serial of the particular device is a little bit tricky. In my next post I will describe step by step description of my shell script to get the serial of given device.
All methods given above and my script is tested on following Linux flavours:
Fedora 8,11 and 13
Mandriva Linux 2010.1
Linux Mint 9