Finding a unique identifier for SD cards

sd card

I have dozens of SD cards that I need to keep track of for a project. Right now, they each have a number physically written with permanent marker on the outside. This is OK, but I want to see if there is something unique that's built into each SD card that I can record. So far I am aware of:

  • The SD card's CID, which usually (not always???) includes an unique serial number. I can't find a straightforward way to read this off an SD card in Fedora 21. Some pages say that unless you have a card reader directly connected to the PCI bus (and not via USB), you can't see the CID.
  • Volume/partition serial number. This might work but I understand that this changes every time the card is reformatted, which is something we do from time to time. So not a good option.
  • Just labelling the SD card volume with my own unique naming system. This is too easy to change, and I might as well just stick with writing the numbers on the outside.

So, I guess my questions are:

  1. Is there a way to reliable read the CID off my SD cards to get serial numbers via a USB card reader in Fedora 21 or other GNU/Linux distributions?
  2. If not, are there other ways of using existing unique identifiers in an SD card or another system for uniquely identifying SD cards?

Best Answer

blkid(8) is probably what you're looking for. It will give the UUID of each device.

For vfat, can set UUID using mtools application mlabel(1).

For ext2, ext3, and ext4, e2label(8) can be used to set the UUID.

So if you reformat from time to time, just set the UUID to the same as it was before if needed.

Can't speak for other card readers, but the ones I've used via a USB port pass through the UUID of the SD card.

Related Question