5

I have a 16 GB Transcend SD card and am using it in my smartphone. One day I discovered that the smartphone recognizes it as only 6 GB. I've tried to find the solution to set the correct size of the SD card and accidentally ran this:

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

/dev/sdc is my SD card mounted 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?

I'm hoping to find a Linux equivalent to the SD Association SD Memory Card Formatter (which is a binary-only program only available for proprietary OSes).

Toby Speight
  • 5,213
archer
  • 179

6 Answers6

4

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
  • 5,213
2

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
  • 58,482
1

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
  • 232
1

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
  • 3,264
0

take a known good image... .such as a raspbian image file, and do the same thing again.... dd if=~/Downloads/raspbian.img of=/dev/sdc bs=16M status=progress

That should write a complete good image to the card, including the partition table

-3

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
  • 571