I'm currently working (or you can say, playing) with methods to obtain serial number of disk drives and have observed some scenarios that would like to have explanation. I appreciate any knowledge about them. I'll split the concerns into cases for easy reading.
To getting started, I understand that an USB reports a device identification number in the form
USB\VID_<4 characters of vendor id>&PID_<4 characters of product id>\<identification number>
where the identification number
can be the serial number of the USB, or generated by the system if there isn't one. The identification number is formed by some rules of Windows related to information reported by the bus.
- I have an USB (let's call this A) connected to the PC. Its device instance id is
USB\VID_xxxx&PID_yyyy\6&123456&1
. I beleive that6&123456&1
is the identification number generated by the system, not the actual serial of A (since it has the 6& prefix and &1 postfix). At the beginning, this ID number persists when I plug A into different port of the PC. However, after some time i callCM_Setup_Devnode
on the USB, this ID changes. Note that this change does not happens every timeCM_Setup_Devnode
is triggered, but it does occasionally
[?] My question: Why doesn't this ID number change on changing the port, but on CM_Setup_Devnode
calls, and on random times?
- I have another USB (let's call this B) and B has a serial X. I can extract this serial from both an USB kernel lower filter driver and SetupDi APIs. However, from the filesystem point of view, I cannot retrieve this using
IOCTL_STORAGE_QUERY_PROPERTY
: it returns only garbage characters. I did a small check using smartctl on the disk drive mounted by B and smartctl also cannot get the serial number of it
[?] My question: Is it true that X is the serial number of the USB only, not the disk inside it? (therefore I cannot get the serial of the disk drive inside the USB)
- I have a Seagate hard disk drive dock (the Seagate dock) and a Samsung HDD. When the HDD is put into the dock, I saw the USB Mass Storage entry in Device Manager, which i think is of the dock. The dock reports its device identification number as
USB\VID_mmmm&PID_nnnn\2JHKDGF
. I thought the2JHKDGF
is the serial number of the dock, however the tag on the dock shows another serial number.
[?] My question: Why is the dock report another serial number than on the tag? Which one should i follow?
- I have another disk drive dock, a Unitek one, which use usbjmicron protocol to communicate between the disk and PC. I put the Samsung HDD into this Unitek dock and check the device identification number of the dock, which now reports the serial number of the HDD in a messy way (the characters of the serial is messed up in an undefined order - not big endian nor little endian). I put another Western Digital Purple HDD (WDP HDD) to the dock, and now the device identification number reports another serial number (which is not of the WPD HDD)
[?] My question: Why is the identification number of the dock inteferred with the serial number of the disks, in a messy way?
- In case (3), the identification number of the Seagate dock persists for all HDD and port connected. In case (4), the identification number of the Unitek dock changes when a new HDD is inserted
[?] My question: Why is that? Does it relate to the protocol used for communication?
- I have a card reader. When I insert my SD card to it and try to get the disk drive information, I can only get the information of the card reader
[?] My question: Why is that? Is it true that the SD card does not specify any disk information and the only thing it store is the data and therefore, it must be read by a reader? If it's correct, then is it true that I cannot distinguish different SD cards?
Final question: I want to identify and distinguish the USB drive, the HDDs, cards, dock and card reader. From the above scenarios, what conclusion bellow is good? What other conclusion should I make, or should I adjust any of them?
-
USB can be identify and distinguished by the device identification number reported by the USB. The serial number (if there is) is also the serial number of the drive inside it
-
Other kinds of disk can be identified by their model, product name, revision (if there is), and serial number
-
Some docks does not have reliable serial number
-
Card readers can be identified by the device identification number
-
SD cards cannot be distinguised
Again, I would like to send thanks for reading my questions and give answers/references to all my concerns.