57

Is there a way to estimate the lifetime of a SD card? If not, is there a utility I can use that monitors its integrity and reliability so I know when to use a new SD card?

7
  • 8
    I'm also confused by the reasoning behind the "close" votes as not constructive. Is it because different SD cards will have different answers?
    – ramblinjan
    Jun 13 '12 at 20:05
  • 2
    What makes it a bad question is that the answers will be guesses
    – finnw
    Jun 13 '12 at 20:52
  • 13
    That would make those answers bad answers. Just because it can't be answered accurately now doesn't mean it can't be accurately answered.
    – ramblinjan
    Jun 13 '12 at 20:57
  • 15
    @finnw - A question which is difficult to answer isn't a bad question, it's a good question! It's a question which people are going to keep on asking, so is perfect for a site intended as a reference for answering questions that people want answered. Bad answers on the other hand can be voted down. Not allowing people to try to answer defeats the purpose of a stack exchange site.
    – Mark Booth
    Jun 14 '12 at 10:28
  • 1
    I don't get these moderators trying to shutdown questions for no good reason. If you want to help, try to improve the question by adding more tags or something. Do something constructive!
    – kaptan
    May 14 '19 at 19:20
14

There are several tools that will check integrity of a filesystem, and recurring errors will point to a SD card reaching the end of its lifetime.

fsck is a commonly used Linux application and you can use it to check a partition like this:

fsck /dev/sdx

Where x is the partition number.

As for estimating the lifetime, the Sandisk Product Manual states:

SanDisk SD cards have an endurance specification for each sector of 100,000 writes typical (reading a logical sector is unlimited).

However, I do not know how many read/writes the typical OS uses on average.

3
  • I think 'typical' would be indescribable. It would be completely dependent on the software installed. It may be possible to calculate the read/writes of a clean install but that will vary with each little update making the statistic fairly meaningless. I think the tools you listed combined with the knowledge that it will take a good while to burn up a card should be sufficient base data to go on. Jun 14 '12 at 16:48
  • @tencent I think it's the best we can do.
    – Jivings
    Jun 16 '12 at 14:21
  • 1
    I'm on Ubuntu Server 20 LTS for Raspberry Pi, and there, the SD card is not on /dev/sdX, but /dev/mmcblk0.
    – Abdull
    Apr 13 at 21:28
17

SD cards do the monitoring themselves, so you don't have to. Modern commercial-grade SD cards will use sophisticated wear leveling algorithms which detect and isolate bad blocks as they appear, so at any given moment no bad blocks are exposed to the file system. That's why HDD tools like badblocks (and by extension fsck) are useless for failure prediction: they will show you the card is fine even if it is already aging.

Things keep going until the SD card runs out of reserved spare blocks, at which point most cards permanently lock themselves to read-only mode. This is intended to give the user a chance to read out the data and move it to another medium. This is how you know you need to get a new one.

Since the card typically runs out of spare blocks while you're writing on it, having journaling enabled greatly helps to recover your data.

If you really want to anticipate a failure, get an SSD and keep your data there. Then you'll be able to use smartctl to check how many blocks have already been relocated internally, and how many more remain, often represented as a percentage of the estimated lifetime of your SSD.

6
  • Very good to know! SD healt should then be possible by see when the size has started to shrink, df -h Oct 29 '19 at 21:07
  • 5
    @DanFroberg No, the size visible to the user will remain constant. It's the pool of reserved blocks that runs out, and that pool is not visible via regular SD card access. Nov 5 '19 at 7:49
  • 1
    Doesn't answer the question
    – Abdull
    Apr 13 at 21:35
  • 3
    @Abdull TL;DR: the SD card needs to be replaced when it becomes read-only. Apr 14 at 7:43
  • Frequently, when the card goes bad is too late, read only or not. Some applications need to anticipate and prepare for that. Additionally being able to collect analytics on actual card performance and wear in the field is also useful. Nov 10 at 20:33
10

You can scan all blocks of your partitions with

time badblocks -sv /dev/mmcblk0p2 -o mmcblk0p2.log

mmcblk0p2 refers to the partition and has to be replaced by the partition to scan. You can list your partitions with lsblk or fdisk -l.

Bad blocks will be recorded to the log file.

Unmounting of the file system is not necessary.

You can also do non-destructive write tests (-n option), if you find it necessary.

If you don't need to preserve the data you can also do faster (destructive) write test (-w option).

5

For ATP branded Industrial SD Cards, they provide "SD Lifetime Monitoring Tool" software for Linux/Windows. But if you use this tool you must run this tool from a Host Operating System. That means you can not use this software inside SD Card to check itself. Because if you run this software, SD card can not be accessable.

For Reference - Google: ATP Industrial Grade SD Card Specification (Revision 3.8)

enter image description here

1
  • Nice but those cards basically do not exists. Can't find any on amazon.fr or other usual websites in EU.
    – MappaM
    May 19 '20 at 15:02
4

I just came across a tool to check Panasonic SD Cards for remaining endurance:

enter image description here

https://av.jpn.support.panasonic.com/support/global/cs/sd/tool/card_checker.html

It only has Mac and Windows versions though.

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.