How to test MicroSD card?

What's a good way to test a MicroSD card? I suspect it may be faulty, but I haven't been able to catch it in the act of going wrong.

I can test in-situ in a Pi, in my MacBook.

Daniele

Reply to
D.M. Procida
Loading thread data ...

If the SD card supports SMART that is a good place to start.

--
Canada is all right really, though not for the whole weekend. 

"Saki"
Reply to
The Natural Philosopher

You can read thewhole card on the Pi it is used in. Open a terminal and type:

lsblk

The response will be something like:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT mmcblk0 179:0 0 7.4G 0 disk

+-mmcblk0p1 179:1 0 41.8M 0 part /boot +-mmcblk0p2 179:2 0 7.4G 0 part /

Now read the whole disk, all partitions with:

sudo dd if=/dev/mmcblk0 of=/dev/null bs=1M

If there are any problems, error messages will show up. Otherwise, the number of records (blocks) in and out will be reported, plus the effective duration and speed.

Hope this helps.

--
Regards, 
Kees Nuyt
Reply to
Kees Nuyt

Perhaps you have access to a Windows environment? I use this program:

formatting link

which runs on Windows and tests the whole SD for read/write. The program has an English language option. I would first check for mechanical faults with a hand-lens visual inspection.

--
Cheers, 
David 
Web: http://www.satsignal.eu
Reply to
David Taylor

On the assumption that you have a USB SD-card reader and another known- good bootable SD card:

- put the known-good card in the RPi's card reader and boot the system

- put the suspect card in the USB reader and plug it in but don't mount any partitions on the card

- now, from the command line: - start cfdisk to get the names of partitions on the suspect card, probably /dev/sdb1 and /dev/sdb2 and stop cfdisk "man cfdisk" will tell you how to use it. - now run fsck against those partitions. "man fsck" tells you how to use fsck - both cfdisk and fsck must be run as root, so either become root to run them or prefix eash commands with 'sudo'

The suggestion to read the entire SD card with dd is a good one, but dd just checks that all partitions are readable, while fsck checks the logical filing system in a partition for errors that may have been caused by, e.g. powering off the RPI without first shutting it down with the "sudo stop" command.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Indeed it does - dozens of errors (so far), for the same inodes.

I think the card has reached the end of its life here.

Daniele

Reply to
D.M. Procida

I don't know about you but I'm getting old now with retirement looming. So I don't have the minutes left in my life to waste testing cards going suspect. It seems a better use of my time to go and order several decent cards from a reputable dealer and swap the suspect ones out and to keep some spare.

YMMV

Reply to
mm0fmf

When the card is in a Pi, that command will either produce errors or actually freeze the Pi. Inserted into my MacBook, the same operation (copying to /dev/null) works without issue.

Daniele

Reply to
D.M. Procida

That's all very well, if you're confident that the source of the problems have been the card, rather than the Raspberry Pi, the external disk drive, the PSU...

Daniele

Reply to
D.M. Procida

Which says that the card is still physically undamaged, or at least has enough undamaged pages to map its advertised data capacity onto.

However, you don't seem to have looked at the logical structure of any partitions yet, so what does fsck tell you about that? If it reports that a partition's logical structure is damaged, can fsck repair it?

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

That?s a somewhat unexpected response, since dd doesn?t know anything about inodes.

Per your other post, if it works on a Mac but not an RPi, you?ve not yet distinguished the situation from a broken RPi or some kind of compatibility issue (although I think the card being broken is most likely).

formatting link
can be used to do a _destructive_ write-read test of the whole medium. It can build for both Linux and macOS.

--
https://www.greenend.org.uk/rjk/
Reply to
Richard Kettlewell

That'll be good right up until the day the problem is a dodgy interface that destroys cards.

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:\>WIN                                     | A better way to focus the sun 
The computer obeys and wins.                |    licences available see 
You lose and Bill collects.                 |    http://www.sohara.org/
Reply to
Ahem A Rivet's Shot

You're right. But experience so far has shown all the cards I have that have failed have been through "wearing out" rather than anything else. I've had USB memory sticks fail for no good reason but not SD cards. As I said, YMMV.

Reply to
mm0fmf

In case you mean you can test either in the Pi _or_ in another machine, for a write-read test the following command pipeline will generate a non-repeating pattern:

yes '' | cat -n | tr -d ' \t' | pv -prb

The 'pv' part is optional if you don't want to see progress.

You can use 'dd' to write the pattern to the card, and then 'diff' with '-' as one argument to verify.

HTH

--
Robert Riches 
spamtrap42@jacob21819.net 
(Yes, that is one of my email addresses.)
Reply to
Robert Riches

Use this:

formatting link

Bye Jack

--
Yoda of Borg am I! Assimilated shall you be! Futile resistance is, hmm?
Reply to
Jack

Seems an amazingly complex way to generate a sequence of ascending numbers...

--
When plunder becomes a way of life for a group of men in a society, over  
the course of time they create for themselves a legal system that  
authorizes it and a moral code that glorifies it.
Reply to
The Natural Philosopher

Use the right tools for the job - the badblocks command for example.

In a Pi:

sudo badblocks -c 1024 -s /dev/mmcblk0

(That took just over 5 miuntes to test an 8GB SD card in a 4 year old A+)

On other Linux systems, then the /dev/mmcblk0 may well be different. I've no idea if Mac has the badblocks command but it would surprise me if it didn't.

The badblocks command can also do a variety of write tests too, but I do not recommend it on a live filesystem, and when you do put the SD card into a different system, make sure it does not get auto-mounted, or if it does, unmount it before running and write tests on it.

On the Pi there are other factors though - and you may well see a card fail on the Pi and pass elsewhere - the common culprit in the Pi world is the PSU and overclocking. Turn all overclocking off and make sure you have a good reliable PSU (not a cheap charger)

-Gordon

Reply to
Gordon Henderson

It's not available on MacOS or FreeBSD (where the MacOS CLI mostly came from).

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:\>WIN                                     | A better way to focus the sun 
The computer obeys and wins.                |    licences available see 
You lose and Bill collects.                 |    http://www.sohara.org/
Reply to
Ahem A Rivet's Shot

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.