9

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?
  • 1
    FYI: You're not really expected to reply to each answer. Though voting up/down on them and, if one solves your problem, picking it as your accepted answer are definitely appreciated. – derobert Apr 17 '15 at 17:17
  • @derobert Understood, thanks for the info! – hpy Apr 17 '15 at 17:59
3

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.

  • 1
    Sounds promising, thanks!! What about fat32? – hpy Apr 22 '15 at 10:46
  • 1
    Yes I believe mlabel(1) supports fat32 as well. – JonathanS Apr 22 '15 at 12:54
  • 1
    whatever blkid returns will change whenever the data stored on the SD-card changes. This is much different to the CID or serial number. If you made a dd if=/dev/sdcard1 of=/dev/sdcard2 count=2, changes are very hight that blkid /dev/sdcard1 will be identical to blkid /dev/sdcard2. Also the final remark of the answer is misleading: the UUID is derived from the data stored on the SD card, and not the card, clearly most every USB reader will let you read the content of th SD-card. What is still not possible is to access the CID. – humanityANDpeace Mar 8 '17 at 14:00
3

Based on @humanityAndpeace comment, Looking for CID could be a solution, but it seems that you cannot get it from all sd cards. At least it is the case for one I tested. See more documentation here.

The idea is to get infos from /sys/block/<yourBlockDevice>/device/cid

Note: you can read <yourBlockDevice> from sudo dmesg after plug in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.