USB Unique ID

Before you remove a flash drive you should eject it. When you plug in a different identical device Windows will mount it afresh, so there should be no problem with “Windows thinking it is the same drive” (in fact I think Windows uses unique information in the drive’s metadata to prevent any confusion here).

If you are swapping flash drives without unmounting I think any problems you observe are more likely to be from damaged data from unplugging than Windows thinking they are the same drive. Either way it’s an experiment that is guaranteed to fail and doesn’t teach anything about the serial numbers.

Mike

----- Original Message -----
From: Ian Bannerman
To: Windows System Software Devs Interest List
Sent: Tuesday, May 20, 2014 5:49 PM
Subject: RE: [ntdev] USB Unique ID

Serial number must be unique for each device.
>
> If it is not so - you can just omit the serial number from the descriptor, this is OK.
>
> Having the same serial numbers is NOT OK, a gross violation of the USB spec, and some Windows versions will just crash if 2 such devices are inserted.
>

I looked into this for similar ‘How can I identify this device’ reasons a year ago or so and I could not locate a way to uniquely identify flash drives that either don’t have or present the same serial number. I didn’t encounter any crashes testing on XP+, but definitely ran into quirks. For example, each time such a flash drive was connected to a new port Windows installs the device anew. Swap one flash drive without the unique id with another and Windows would think they’re the same device, regardless of data, formatting, etc.

This MSDN article talks about querying for this info and some such fail cases - http://msdn.microsoft.com/en-us/library/windows/hardware/ff551679(v=vs.85).aspx

–Ian


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

>If you are swapping flash drives without unmounting I think any problems you
observe are more likely to be from damaged data from unplugging than Windows
thinking they are the same drive.

The cache will be discarded no matter what. There will be no memory of it. Eject only guarantees the flush of dirty pages.

The volume is identified by different means than the container instance ID.

> >If you are swapping flash drives without unmounting I think any problems you

observe are more likely to be from damaged data from unplugging than Windows
thinking they are the same drive.

The cache will be discarded no matter what. There will be no memory of it. Eject only guarantees the flush of dirty pages.

The volume is identified by different means than the container instance ID.

In my case my environment was already encountering flash drives that did not have serial numbers & had identical volumes out of the box, thus presenting me with this identification issue. The problems I mentioned are reproducible regardless of data on a drive, so damaged data was not at play. And of course, even if safely ejecting could help, I can hardly convince my entire user base to do so every time. It may be good advice, but I can’t ever count on it.

Sadly flash drives like these aren’t rare. As an example, Best Buy currently sells a few PNY models that do this.
–Ian