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
  • 4,866
  • 1
  • 26
  • 36
archer
  • 179
  • 1
  • 1
  • 7
  • 1
    Is it still available under `/dev/sdc`? – gronostaj Nov 15 '13 at 15:43
  • 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](http://gparted.sourceforge.net/) would be the easiest answer. – Bobby Nov 15 '13 at 15:57
  • 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 Nov 15 '13 at 17:27
  • 1
    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 Mar 19 '15 at 03:01
  • 2
    Can you use a different sd reader instead of your phone, and see if that works? I personally wouldn't trust a smartphone to be a usb sd reader if I'm fiddling around with partitions (but just moving files around is fine). Or you could try partitioning with the phone itself instead of through it, if you're on android. https://github.com/LegacyXperia/Wiki/wiki/Partitioning-the-SD-Card-using-ADB (this should give you the gist of what to do, but it's not a 1:1 guide for any android phone, except xperia phones. – Alexander M Mar 25 '20 at 10:29

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
  • 4,866
  • 1
  • 26
  • 36
  • 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 May 07 '15 at 05:42
  • If you can't drive it at all with `hdparm` or any partition editor, it's likely that your phone is interpreting the empty blocks as "no card". At this stage, I'd try using a dedicated card reader - perhaps borrow a USB one from a friend? – Toby Speight Jan 22 '21 at 00:43
  • 1
    If you run `sudo systemctl -f` and then insert the card and nothing happens, there's nothing you can do because that card is then electronically dead. If some error messages show up, there's your clue to go forward with the investigation. And if you see a line containing something like `sd 6:0:0:0: [sdd] 15955968 512-byte logical blocks` then you know the device is `/dev/sdd` instead of the letter you expected it to be. And if the size of the *device* is incorrect, it's possible that no data can be recovered at all. – Mikko Rantalainen Jul 16 '23 at 08:59
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
  • 55,965
  • 20
  • 120
  • 179
  • As I already stated, when I try to access `/dev/sdc` it says `No medium found` – archer Nov 16 '13 at 10:01
  • Access how? Have you tried the steps above? – gronostaj Nov 16 '13 at 13:21
  • 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 Nov 16 '13 at 15:38
  • 1
    *No medium found* when you try to do what? To "access" device is a very broad term. – gronostaj Nov 16 '13 at 17:09
  • to `fdisk -l /dev/sdc` for example. or to `fsck /dev/sdc` - does not matter – archer Nov 17 '13 at 11:45
  • 1
    You 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 Nov 17 '13 at 12:02
  • Man, neither gparted nor fdisk sees my sd-card. – archer Nov 17 '13 at 12:23
  • 1
    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 May 07 '15 at 16:26
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
  • 222
  • 2
  • 12
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,228
  • 13
  • 29
  • 38
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
  • 3
  • 13
  • 3
    Please 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 Nov 15 '13 at 15:49
  • 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 Nov 15 '13 at 16:31
  • There's no filesystem at all. SD Card is not recognizable (this happened after `dd if=/dev/zero of=/dev/sdc` – archer Nov 15 '13 at 17:29