Getting hard drive serial number from USB devices
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Mon Jan 16 21:25:13 UTC 2006
Lennart Sorensen wrote:
> On Sat, Jan 14, 2006 at 02:29:35PM -0500, Madison Kelly wrote:
>> Peter wrote:
>>> lsusb -v|...|grep iSerial
>> Thanks for the reply!
>>
>> Unfortunately, that only gives the serial number of the USB
>> controller, not the hard drive itself. This is a problem because I use
>> USB drives with removable disk carriers. If I rely on the USB/IDE ASIC's
>> serial number my program would not be able to tell the difference
>> between different hard drives connected through the common carrier.
>
> What filesystem do you format the drives with?
>
> If you use ext2/ext3 you can do this:
> tune2fs -l /dev/sda1 |grep UUID
>
> There are probably similar things you can do on other filesystems.
>
> Each filesystem is assigned a unique id, which is a very reliable way to
> identify a drive. If you reformat it, the ID changes of course, but at
> that point it is a new filesystem and hence would have none of the old
> data anymore.
>
> Len Sorensen
Currently I use the 'UUID' of a partition as assigned by 'blkid' and
that works fine with a few exceptions. Those exceptions are the cases I
am trying to work around. Specifically;
- The UUID of a permission changes if that partition is reformatted.
- No UUID is assigned to some file systems (ie: NTFS).
- On some file systems 'blkid' assigns a generic '0000-0000' UUID (ie:
'vfat' on digital cameras).
Being a backup program I want to, ideally, support all file systems.
This is why reading the serial number would be so ideal; I could create
a (slightly modified) MD5 hash of the drive's serial number +
partition/slice number to create a file system agnostic, portable ID.
If I *can't* get the serial number over a USB interface (as seems to
be the case now), then I need to find another method to uniquely
identify a physical disk. The problem is, often people who use my
program will buy a bunch of disk drives at once, often only in a series
of serial numbers. So relying on things like the model number or date
code would also be troublesome.
Gah!
Why couldn't disk drive manufacturer's put a small sector or two
aside with the information always available and outside the view of the
rest of the disk space? That would be sooooo nice!
Madison
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Madison Kelly (Digimer)
TLE-BU; The Linux Experience, Back Up
Main Project Page: http://tle-bu.org
Community Forum: http://forum.tle-bu.org
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list