Oh, it's much worse than that. Counterfeit cards are often manipulated to lie to the OS about their capacity as well. They don't "fill up" at all, they just throw away your data, or overwrite it silently.
Oh, it's much worse than that. Counterfeit cards are often manipulated to lie to the OS about their capacity as well. They don't "fill up" at all, they just throw away your data, or overwrite it silently.
Then the card corrupted all of my photos.
dd if=/dev/urandom bs=1048576 count=5000 | tee test.bin | md5sum
(substitute bs=1048576 count=5000 with the actual size of the sd card) then do md5sum test.bin
and check whether the two hashes match.Maybe someone will come along and provide references to a a definitive answer on what the behaviour will be.
My point is: it's not trivial to ensure that you're actually testing the right thing.
True, but this doesn't necessarily guarantee that the subsequent read will come from the card and not the cache.
It might as currently implemented; I don't know. But without specific evidence that it does and will continue to do so indefinitely, I wouldn't assume it for verification purposes.
I make the same point again: it's not trivial to ensure that you're actually testing the right thing.
Unplugging and replugging the card really should invalidate the cache though.
dd bs="$(blockdev --getsize64 "$device")" count=1 if=/dev/urandom of=random-file
dd if=random-file of="$device"
cmp random-file "$device"
Using cmp instead of something like md5sum is better since it would stop on the first differing byte, instead of reading the whole thing for both.EDIT: I'm not sure if my use of dd's bs and count is a good idea, though. It might be better to do:
head -c "$(blockdev --getsize64 "$device")" /dev/urandom > random-file
to get more reasonable buffer sizes. Documentation on head says -c works on bytes, not characters, so that's good.For that second line, I often prefer to do:
pv random-file > "$device"
to get a neat progress bar.EDIT 2: As discussed in other threads, one should make sure to invalidate the kernel's cache of the device between steps 2 and 3. My safest bet on how to do that is to reboot the computer.