FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 02-06-2009, 04:28 AM
Iain Buchanan
 
Default testing a corrupt SD card

Hi all,

recently my SD card just went bonkers. Unfortunately I lost a lot of
photos on it (backups are useless until the data actually gets to the
backup...) but fortunately I was able to use a program to recover about
170 photos.

Anyway, I don't know if it was just static, shock, dead card, or phase
of the moon, so I would like to see if the card is good before I
continue to use it.

I've reformatted it and I get:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk0p1 500960 500960 0 100% /media/PICS

so I created a file:
dd if=/dev/urandom of=Desktop/random.img bs=1024 count=500960

then copied it to the card, and then copied it back as random-2.img. If
I md5sum the two files, they are identical:
$ md5sum random*
9dcac25cfd8585be5939c0ff969de310 random-2.img
9dcac25cfd8585be5939c0ff969de310 random.img

Does that mean my memory card is good to go, or should I use some other
method of bad sector detection?

It's a Lexar Media 512Mb SD card, a couple of years old. Yes I know I
can get a cheap 2Gb for <$20 but I'm more interested in the principle of
the test

thanks for any tips!
--
Iain Buchanan <iaindb at netspace dot net dot au>

This sentence contradicts itself -- no actually it doesn't.
-- Douglas Hofstadter
 
Old 02-06-2009, 06:11 AM
Stroller
 
Default testing a corrupt SD card

On 6 Feb 2009, at 05:28, Iain Buchanan wrote:

It's a Lexar Media 512Mb SD card, a couple of years old. Yes I know I
can get a cheap 2Gb for <$20 but I'm more interested in the
principle of

the test


I thought you could get then for < $5, but anyway....


so I created a file:
dd if=/dev/urandom of=Desktop/random.img bs=1024 count=500960

then copied it to the card, and then copied it back as
random-2.img. If

I md5sum the two files, they are identical:
$ md5sum random*
9dcac25cfd8585be5939c0ff969de310 random-2.img
9dcac25cfd8585be5939c0ff969de310 random.img

Does that mean my memory card is good to go, or should I use some
other

method of bad sector detection?


I'd be more or less happy with that methodology, had I copied a
thousand files to the card & they checked out good.


Of the top of my head I don't know how big your "bs=1024 count=500960"
file is - I would make a Bash script generate files c 5meg in size
(maybe alternative between 3meg & 6meg?) and copy them to the card
until it fills up. Then check them, delete them and do so again until
all 1000 have been copied & checked.


Personally, I wouldn't be happy with one file being copied & stored
ok, but I'd probably be happy if the card had proved itself to safely
store 1000. And 3meg - 6meg is the size of the jpegs taken by my mum's
camera. I would want to fill up the card, as flash cards try to avoid
the bad blocks - if you don't fill it, you could be missing some duff
block every time; once you've filled it you know that all the blocks
are good. For some values of "good", that is - you don't know about
longevity, and these cards are really just black boxes to us - we have
no idea what magic goes on inside.


Personally, for my money, I don't know if I'd trust it. Depends what
you're storing on it. MP3s for my phone? Sure - I have a backup at
home. Moving files onto my PS3 or Wii, sure. For my camera? Maybe I'd
be a bit cautious.


Stroller.
 
Old 02-06-2009, 03:47 PM
James
 
Default testing a corrupt SD card

Iain Buchanan <iaindb <at> netspace.net.au> writes:


> Does that mean my memory card is good to go, or should I use some other
> method of bad sector detection?

Hello Iain,


Hard to tell. Even repeated memory tests may/maynot find your gremlin,
i.e. bad memory. Also, just because it failed once, does not
mean the mem/card is bad. Transients occur giving false bit readings.
Sometimes you can delve into how the memory is actually made, but,
most vendors protect that info, with NDA and such, mostly smoke screens.

Here are a couple of links for your perusal:

http://en.wikipedia.org/wiki/Secure_Digital_card#SDHC

http://www.sandisk.com/Assets/File/OEM/Manuals/SD_SDIO_specsv1.pdf


Sorry, there is not a clear answer. Keep it for non critical needs,
upgrade to SDHC(fat 32) if your equipment supports that format.
Fat 32 on top of the memory, helps with (bit)error masking with
some enhance (undocumented) feature not part of fat 32. This is
what makes reverse engineering, complicated on SD memory.
You may need to upgrade the firmware of your equipment to support
newer SD standards (SD 1.1 and SD 2.0).


Good luck and good hunting (mate).....


James
 
Old 02-06-2009, 09:21 PM
Stroller
 
Default testing a corrupt SD card

On 6 Feb 2009, at 05:28, Iain Buchanan wrote:

...
so I created a file:
dd if=/dev/urandom of=Desktop/random.img bs=1024 count=500960


It has just occurred to me:

In the UK you can be imprisoned for failing to provide an encryption
key corresponding to this file.


Stroller.
 
Old 02-07-2009, 12:36 AM
Paul Hartman
 
Default testing a corrupt SD card

On Thu, Feb 5, 2009 at 11:28 PM, Iain Buchanan <iaindb@netspace.net.au> wrote:
> Hi all,
>
> recently my SD card just went bonkers. Unfortunately I lost a lot of
> photos on it (backups are useless until the data actually gets to the
> backup...) but fortunately I was able to use a program to recover about
> 170 photos.
>
> Anyway, I don't know if it was just static, shock, dead card, or phase
> of the moon, so I would like to see if the card is good before I
> continue to use it.

With any kind of memory or storage device, I would stop using after
the first sign of a problem. My personal experience says it only gets
worse.

Lexar has a free program for recovering corrupted/deleted files from
their cards, did you use that? Or something linux-based like photorec?
Anyway, you wrote over it so it's too late now.

I would try any kind of "torture test" you can think of on it. Also be
sure to unmount/remove and reinsert it a few times. I have encountered
cards that only work 1 out of 4 times they are inserted into the card
reader, etc. Maybe the contacts are worn if it's a few years old?

Some (all?) memory cards do wear-leveling/load balancing so when you
write to sector 13 it might not be the same sector 13 as last time, so
doing any kind of repeated error testing might be difficult. In fact,
if the card detects bad spots it may simply hide them from you. There
may be programmatic ways to bypass the card's wear-leveling, but I
don't know how.

Good luck! In case you can't get it working reliably, Newegg has an
8gb CF card for $19.99 & free shipping

Paul
 
Old 02-07-2009, 12:38 AM
Paul Hartman
 
Default testing a corrupt SD card

On Fri, Feb 6, 2009 at 7:36 PM, Paul Hartman
<paul.hartman+gentoo@gmail.com> wrote:
> Good luck! In case you can't get it working reliably, Newegg has an
> 8gb CF card for $19.99 & free shipping

Oops, never mind that part, I see you're in AU not US. My mistake! I
am an American after all, sometimes we forget other countries exist.


Paul
 
Old 02-10-2009, 11:50 PM
Iain Buchanan
 
Default testing a corrupt SD card

On Fri, 2009-02-06 at 07:11 +0000, Stroller wrote:
> On 6 Feb 2009, at 05:28, Iain Buchanan wrote:
> > It's a Lexar Media 512Mb SD card, a couple of years old. Yes I know I
> > can get a cheap 2Gb for <$20 but I'm more interested in the
> > principle of
> > the test
>
> I thought you could get then for < $5, but anyway....

probably in USD. We (AUD) were approaching 1.00 before the exaggerated
crises, but now we're back to 0.645; and plus I needed one in a hurry,
so I couldn't order from a PC store which has reasonable prices and
instead had to go for a local and slightly more expensive retailer...

> > so I created a file:
> > dd if=/dev/urandom of=Desktop/random.img bs=1024 count=500960
> >
> > then copied it to the card, and then copied it back as
> > random-2.img. If
> > I md5sum the two files, they are identical:
> > $ md5sum random*
> > 9dcac25cfd8585be5939c0ff969de310 random-2.img
> > 9dcac25cfd8585be5939c0ff969de310 random.img
> >
> > Does that mean my memory card is good to go, or should I use some
> > other
> > method of bad sector detection?
>
> I'd be more or less happy with that methodology, had I copied a
> thousand files to the card & they checked out good.
>
> Of the top of my head I don't know how big your "bs=1024 count=500960"

well, I got that from the free space on the card, using df and some
mathemagics, so it 100% fills the free space... however...

> file is - I would make a Bash script generate files c 5meg in size
> (maybe alternative between 3meg & 6meg?) and copy them to the card
> until it fills up. Then check them, delete them and do so again until
> all 1000 have been copied & checked.

[snip]

however my method and your suggestion only fill up the free space, and
not the FAT for example, so there could be corruptions there, and given
I could see files but the names were nnnxxnnxnnn.ddxxc and so on, I
think it could have been a corrupt FAT?...

I should have made a file the size of the whole SD card, and just
written it to and read from the device a couple of times, overwriting
the partition table, and FAT.

> Personally, for my money, I don't know if I'd trust it. Depends what
> you're storing on it. MP3s for my phone? Sure - I have a backup at
> home. Moving files onto my PS3 or Wii, sure. For my camera? Maybe I'd
> be a bit cautious.

Bought a new 2Gb. Unfortunately I want a 512Mb card cause then I'm
forced to back it up often enough.

--
Iain Buchanan <iaindb at netspace dot net dot au>

Men have a much better time of it than women; for one thing they marry later;
for another thing they die earlier.
-- H.L. Mencken
 
Old 02-10-2009, 11:54 PM
Iain Buchanan
 
Default testing a corrupt SD card

On Fri, 2009-02-06 at 16:47 +0000, James wrote:
> Iain Buchanan <iaindb <at> netspace.net.au> writes:
>
>
> > Does that mean my memory card is good to go, or should I use some other
> > method of bad sector detection?
>
> Hello Iain,

Hi James!

[snip]

> Here are a couple of links for your perusal:

Unfortunately I'm travelling, and the company here has a draconian
internet policy that doesn't allow much of anything. I'll have to check
them out in a couple of weeks.

> Sorry, there is not a clear answer. Keep it for non critical needs,
> upgrade to SDHC(fat 32) if your equipment supports that format.

unfortunately not!

> Fat 32 on top of the memory, helps with (bit)error masking with
> some enhance (undocumented) feature not part of fat 32. This is
> what makes reverse engineering, complicated on SD memory.
> You may need to upgrade the firmware of your equipment to support
> newer SD standards (SD 1.1 and SD 2.0).

not much chance of that either (camera). The more I look into it, the
solid state features (moving bad blocks around in firmware and hiding it
from the system) make me think it's time to throw it out anyway...

> Good luck and good hunting (mate).....

cheers, mate!
--
Iain Buchanan <iaindb at netspace dot net dot au>

I might have gone to West Point, but I was too proud to speak to a congressman.
-- Will Rogers
 
Old 02-10-2009, 11:54 PM
Iain Buchanan
 
Default testing a corrupt SD card

On Fri, 2009-02-06 at 22:21 +0000, Stroller wrote:
> On 6 Feb 2009, at 05:28, Iain Buchanan wrote:
> > ...
> > so I created a file:
> > dd if=/dev/urandom of=Desktop/random.img bs=1024 count=500960
>
> It has just occurred to me:
>
> In the UK you can be imprisoned for failing to provide an encryption
> key corresponding to this file.

are you joking? what's the story there?
--
Iain Buchanan <iaindb at netspace dot net dot au>

< DanielS> still, throne of blood sounds like a movie about overfiend
and virgins or some crap
-- in #debian-devel
 
Old 02-10-2009, 11:59 PM
Iain Buchanan
 
Default testing a corrupt SD card

On Fri, 2009-02-06 at 19:36 -0600, Paul Hartman wrote:
> On Thu, Feb 5, 2009 at 11:28 PM, Iain Buchanan <iaindb@netspace.net.au> wrote:
> > Hi all,
> >
> > recently my SD card just went bonkers. Unfortunately I lost a lot of
> > photos on it (backups are useless until the data actually gets to the
> > backup...) but fortunately I was able to use a program to recover about
> > 170 photos.
> >
> > Anyway, I don't know if it was just static, shock, dead card, or phase
> > of the moon, so I would like to see if the card is good before I
> > continue to use it.
>
> With any kind of memory or storage device, I would stop using after
> the first sign of a problem. My personal experience says it only gets
> worse.
>
> Lexar has a free program for recovering corrupted/deleted files from
> their cards, did you use that? Or something linux-based like photorec?
> Anyway, you wrote over it so it's too late now.

Now you tell me there are free versions?! I ended up finding a photo
recovery tool which recovered the photos for me, but it wasn't "free".
Needless to say I didn't pay for it, and I deleted it straight away.

I'll check out photorec next time. I'm having a hard time finding info
about it though (see previous email about draconian internet access).

Is there a general linux version of FAT recovery tools available
somewhere? I couldn't find one.

[sinp]

> Some (all?) memory cards do wear-leveling/load balancing

This is what I was afraid of.

thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>

Beware the new TTY code!
 

Thread Tools




All times are GMT. The time now is 02:58 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org