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).

5
  • 1
    Is it still available under /dev/sdc?
    – gronostaj
    Commented Nov 15, 2013 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 would be the easiest answer.
    – Bobby
    Commented Nov 15, 2013 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
    Commented Nov 15, 2013 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 superuser.com/a/774673/48920, askubuntu.com/a/498797/41567 and/or dedoimedo.com/computers/low-level-formatting.html
    – naught101
    Commented Mar 19, 2015 at 3: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. github.com/LegacyXperia/Wiki/wiki/… (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. Commented Mar 25, 2020 at 10:29

6 Answers 6

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. ;-)

3
  • 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
    Commented May 7, 2015 at 5: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? Commented Jan 22, 2021 at 0: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. Commented Jul 16, 2023 at 8: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.

8
  • As I already stated, when I try to access /dev/sdc it says No medium found
    – archer
    Commented Nov 16, 2013 at 10:01
  • Access how? Have you tried the steps above?
    – gronostaj
    Commented Nov 16, 2013 at 13:21
  • 1
    No medium found when you try to do what? To "access" device is a very broad term.
    – gronostaj
    Commented Nov 16, 2013 at 17:09
  • 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
    Commented Nov 17, 2013 at 12:02
  • 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? Commented May 7, 2015 at 16:26
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.

2
  • 1
    Actually I'm looking for Linux alternative of this app.
    – archer
    Commented Nov 17, 2013 at 11:53
  • gparted should work
    – brotich
    Commented Aug 19, 2014 at 8:47
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.

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

0
-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.

3
  • 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
    Commented Nov 15, 2013 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
    Commented Nov 15, 2013 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
    Commented Nov 15, 2013 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .