How to repair an SD card which shows incorrect size?

3

3

I've a Transcend SD card for 16 GB and am using it in my smartphone. One day I've discovered that the smartphone recognize it as 6 GB only. I've tried to find the solution to set the correct size of the SD card and accidenally did that:

dd if=/dev/zero of=/dev/sdc 

/dev/sdc is my SD card mouned via the phone. After that, my card is not recognized at all (neither by the phone, nor by the camera nor by the Linux machine). I understand I've broken some kind of MBR on it (some initial record which shows SD card necessary parameters).

I'm using Linux and don't have Windows at all. I found some solutions for Windows (for example, SDFix application), but is there a Linux alternative? Is it possible to repair?

Actually I'm looking for a Linux alternative of this application: https://www.sdcard.org/downloads/formatter_4/

archer

Posted 2013-11-15T14:19:46.897

Reputation: 159

When you do sudo hdparm -I /dev/sdc, do you see a SG_IO: bad/missing sense data ... message? If so, you might want to check http://superuser.com/a/774673/48920, http://askubuntu.com/a/498797/41567 and/or http://www.dedoimedo.com/computers/low-level-formatting.html

– naught101 – 2015-03-19T03:01:51.637

1Is it still available under /dev/sdc? – gronostaj – 2013-11-15T15:43:44.510

You successfully wiped your SD card (you overwrote everything with zeros). If there was important data on it you might want to contact a data recovery company near you (note: they will most likely not be able to help you). You just need to create a new partition and format it, gParted would be the easiest answer.

– Bobby – 2013-11-15T15:57:47.357

Man, I didn't have any data on that card. I'm just saying that after this operation my card is not recognizabl at all. Trying to access /dev/sdc says No medium found. – archer – 2013-11-15T17:27:56.910

Answers

1

Your card doesn't work because it doesn't have any filesystem. You can use GParted to create one.

In the GParted window choose /dev/sdc. Use appropriate menu option to create new MS-DOS partition table (GParted may automatically prompt you to do it). Then create new partition using entire available space. Click Apply and wait until the process completes. After that your card should be working just fine.

gronostaj

Posted 2013-11-15T14:19:46.897

Reputation: 33 047

If you can't drive it at all with hdparm or any partition editor, it's possible that your card reader is interpreting the empty blocks as "no card". At this stage, I'd try a different card reader - perhaps borrow a USB one from a friend? – Toby Speight – 2015-05-07T16:26:43.550

As I already stated, when I try to access /dev/sdc it says No medium found – archer – 2013-11-16T10:01:58.163

Access how? Have you tried the steps above? – gronostaj – 2013-11-16T13:21:22.393

As I said above initially my 16Gb been accessible as 6Gb card. After dd if=/dev/zero of=/dev/sdc I've got in completelly unaccessible. Means No medium found. – archer – 2013-11-16T15:38:59.743

1No medium found when you try to do what? To "access" device is a very broad term. – gronostaj – 2013-11-16T17:09:23.643

to fdisk -l /dev/sdc for example. or to fsck /dev/sdc - does not matter – archer – 2013-11-17T11:45:56.960

1You don't have any partitions on your card, that may be the reason why both those commands fail. Have you actually tried the steps I have provided? – gronostaj – 2013-11-17T12:02:33.540

Man, neither gparted nor fdisk sees my sd-card. – archer – 2013-11-17T12:23:46.607

1

You have overwritten the card's partition table.

Most consumer embedded devices require a BIOS (PC) partition table, and I'll guess that your phone is such a device. My experience is with cameras; I guess that a phone is probably similar. I'll also assume, that unlike my cameras, the phone doesn't have a 'reformat memory card' action hidden in its menus somewhere.

# cfdisk /dev/sdc

should enable you to re-partition the media (interactively, with no writes until you explicitly okay it). You probably want to create one partition, using all the space.

Having done that, you should find that /dev/sdc1 appears (hdparm -z may be your friend if not), and it's time to create a filesystem on it. Again guessing, I think you'll probably want a VFAT filesystem, unless your device's manual says otherwise:

# mkfs -t vfat /dev/sdc1

Now all that's left is to restore the data from the backup you made before you started meddling. ;-)

Toby Speight

Posted 2013-11-15T14:19:46.897

Reputation: 4 090

the problem is that cfdisk /dev/sdc is impossible as my system does not see /dev/sdc (it completely stopped to recognize that card as external storage device). – archer – 2015-05-07T05:42:29.170

0

Perhaps this utility - F3 by Digirati will be of use. I can not test it at the moment but among other things it promises:

f3probe is the fastest way to identify fake drives and their real sizes. f3fix enables users to use the real capacity of fake drives without losing data. f3brew helps developers to infer how fake drives work. f3probe, f3fix, and f3brew currently runs only on Linux.

Spikolynn

Posted 2013-11-15T14:19:46.897

Reputation: 202

0

You can try a low level reformat. Download the format program from http://sdcard.org/downloads/formatter_4. Set the "Format Size Adjustment" option on. This will re-flash the card irrespective of the filing system – or lack thereof – on the card.

Chenmunka

Posted 2013-11-15T14:19:46.897

Reputation: 3 019

gparted should work – brotich – 2014-08-19T08:47:26.197

1Actually I'm looking for Linux alternative of this app. – archer – 2013-11-17T11:53:07.813

-2

You could try using FSCK to check and repair. First off make sure the card is attached to your Linux box and then;

fsck -a /dev/sdc

The -a switch is used to 'attempt' to fix any errors. There's a bit more info on FSCK options here; http://www.thegeekstuff.com/2012/08/fsck-command-examples/

Alternatively you could use something like GParted (http://gparted.sourceforge.net/livecd.php) to boot a live CD and then delete all the partitions on the SD Card and reformat it.

sgtbeano

Posted 2013-11-15T14:19:46.897

Reputation: 575

2Please correct me, but wouldn't a filesystem check need a filesystem to begin with? But according to OPs descriptions it's completely wiped. And booting a LiveCD just to format an SD Card is a little bit overkill. – Bobby – 2013-11-15T15:49:15.650

As I already said there are no partitions, previously (when it was recognized) fdisk -l shown it's total size is 6Gb. However card is 16Gb in size. – archer – 2013-11-15T16:31:36.497

There's no filesystem at all. SD Card is not recognizable (this happened after dd if=/dev/zero of=/dev/sdc – archer – 2013-11-15T17:29:22.600