Sd Card Identifier
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.
Using SD Formatter Tool to restore full capacity on SDHC/SDXC cards. If you experience this issue you will need to use a reader or host that supports the full capacity of the card and use the SD formatter to recover the full capacity. WARNING: Formatting will erase all data on the card. Back up all your data before proceeding.
So, I guess my questions are:
- 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?
- If not, are there other ways of using existing unique identifiers in an SD card or another system for uniquely identifying SD cards?
2 Answers
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.
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
Not the answer you're looking for? Browse other questions tagged sd-card or ask your own question.
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:
Sd Card Numbers
- 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?
- If not, are there other ways of using existing unique identifiers in an SD card or another system for uniquely identifying SD cards?
Sd Card Identification Register
2 Answers
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.
Sd Card Cid
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