LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-07-2011, 04:41 PM   #1
izghitu
Member
 
Registered: Oct 2005
Location: localhost.localdomain
Distribution: CentOS
Posts: 109

Rep: Reputation: 16
get serial number and model of USB drives


Hi,

I have Ubuntu 10.04 LTS.

I have a script that prompts you to insert a USB HDD/memory stick then it needs to determine its serial and model and save it to a file.

The script can determine the device file of the inserted drive(ex: /dev/sdc) and if hdparm -I /dev/sdc works then all is ok. The problem is that not all USB HDDs/memory sticks work with hdparm. When it does not work I get the following:
Code:
root@izghitu:~# hdparm -I /dev/sdc

/dev/sdc:
 HDIO_DRIVE_CMD(identify) failed: Invalid exchange
The other command to get the serial for USB devices of any kind is lsusb -v or lsusb -D /path/to/bus/address

The problem of the first one(lsusb -v) is that it lists all USB devices and there's no way for me to script it to detect the inserted USB drive/memory stick and get the serial/model for it.

The problem with the second one(lsusb -D /path/to/bus/address) is that I do not know how to get the correct USB bus address of the inserted USB drive/memory stick.

So my questions are:
Is there any other way to get the serial number/model of a USB HDD/memory stick using its /dev/sdc device file?
Is there any way to link the /dev/sdc device file with the /dev/bus/usb/address device file so I can then use the lsusb -D command to get the required info?
Any other ideas?

Please help

Thanks
 
Old 02-08-2011, 03:42 AM   #2
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
You can find the info by issuing the command 'dmidecode'. For more information in dmidecode refer "man dmidecode"
 
Old 02-08-2011, 03:46 AM   #3
izghitu
Member
 
Registered: Oct 2005
Location: localhost.localdomain
Distribution: CentOS
Posts: 109

Original Poster
Rep: Reputation: 16
did not work

simply running the dmidecode command does not say anything about the USB drive.

running it using the -d switch says the following:
Code:
root@izghitu:~# dmidecode -d /dev/sdc
# dmidecode 2.9
# No SMBIOS nor DMI entry point found, sorry.
anyway I found another workaround. Whenever a USB drive/memory stick is inserted I can see this in dmesg:
Code:
[366230.279366] sd 9:0:0:0: [sdd] Attached SCSI removable disk
9 from the 9:0:0:0: thing can be used to determine the right device:
Code:
root@izghitu:~# cat /proc/scsi/usb-storage/9
   Host scsi9: usb-storage
       Vendor: USB
      Product: Flash Disk
Serial Number: 7006AD3DCCBF2DF1
     Protocol: Transparent SCSI
    Transport: Bulk
       Quirks:
 
1 members found this post helpful.
Old 02-08-2011, 03:52 AM   #4
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
All the best.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get processor model number out of the proc/cpuinfo? KnoeperKalle Linux - Hardware 5 08-04-2010 09:34 AM
USB wireless dongle: do any vendors keep constant chipset for given model number? carolus Linux - Networking 2 02-21-2010 12:07 AM
Finding computer model number paddyjoy Linux - Newbie 3 02-14-2006 11:47 PM
LXer: GNU Philosophy Drives Libre Licence Model LXer Syndicated Linux News 0 01-05-2006 12:31 PM
Determining IBM Model Number co_bofh Linux - Software 4 04-26-2005 08:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration