Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using the Linux area since I'm using Linux apps and utilities.

My phone crashed (several times) and managed to corrupt my microSD card. It no longer appears to have partitions and shows as 32MB rather than 2GB. That's using testdisk. dd and ddrescue only pulled 30.6MB of null off of it.

It isn't a fake, SanDisk branded, purchased from a reputable retailer, and the space has been working perfectly for a year.

I expect it's had it, but I didn't see the harm in asking. Even if I forget about the few files I'd like off of it, formatting will probably leave me with a fairly useless 32MB card.

If anyone has any method of at least repairing the card, it would be much appreciated.

share|improve this question
    
This sounds like a hardware issue, perhaps the card dropping into some antique compatibility mode for some reason. What does /proc/partitions show for that device (e.g. grep sdc /proc/partitions)? Do you get any kernel messages (/var/log/kern.log) when you insert the card? –  Gilles Feb 16 '12 at 22:30
    
Partitions shows just sdb, no sdb1 etc. The log file says pastebin.com/mqESsNiq –  antubis Feb 16 '12 at 23:11
add comment

4 Answers 4

I had this problem. First I tried various formatting methods. Ended up using windows diskpart to 'format quick fs=ntfs' just to see if it would resize properly. It didn't. Then I used this SD card formatting utility recommended on the Raspberry Pi site and it did the trick.

https://www.sdcard.org/downloads/formatter_4/

share|improve this answer
add comment

If you cannot get anything recovered and you just want to try to put it back into a usuable state, follow the dd advice from Renan. If this is your first time doing this, you will need more details.

This will delete everything, so be warned. Unplug all other drives and reboot your computer with a Live Linux disk or risk data loss on a plugged in drive.

Don't plug in your disk yet. Run this command.

sudo fdisk -l

Now plug in your disk and run the command again. You will see an entry that wasn't there before. That entry is your device. Write down that device path. If you haven't unplugged all other devices, DO NOT MIX THIS UP WITH ANOTHER ONE.

It will be something like this:

/dev/sdx

Where the x in sdx is your drives letter.

Now that you found your device type in:

sudo dd if=/dev/zero of=/dev/sdx

where the x in sdx is the letter of your drive. (There should not be a number at the end of your device for this command.)

Wait for it to zero. Now type:

sudo fdisk /dev/sdx

You will need to first create a dos disk label. So choose that option.

After creating a dos disk label, you will need to create a partition. Choose make a partition from the menu. Just hit enter and it will give you the defaults. The defaults will make the partition the maximum size of your usb.

Choose the menu item that says to exit and write changes to disk. Make sure the messages don't have errors. If errors exist, you need to repeat these previous steps (but not zeroing).

Now type

mkfs /dev/sdx1

Again, x is the letter of your drive.

Unplug and plug back in and you should see it auto mounted. It's permission will be set to root, so you may need to adjust them.

Always be weary of this drive in the future. Back everything up. I would have recommended GParted, but I believe it does not recognize zeroed drives.

share|improve this answer
    
I've had lots of fun with hard drives before but thank you for the details. The problem is that the device (sdb) is physically only showing as 32MB, and according to dd, is already full of zeroes. Is formatting it not going to result in a 32MB drive? Like I say, I'll try in a bit anyway. –  antubis Feb 17 '12 at 13:47
    
it should not show anything after you zero. It goes over the disk label and partition info. When you dd make sure you choose /dev/sdb not /dev/sdb1. /dev/sdb is your device in general where /dev/sdb1 is the partition on the device. dd will ignore partition info and go to the physical end. I'm guessing you are showing less mem because the partition table is corrupt. –  bambuntu Feb 18 '12 at 8:26
    
If it truly is a hardware problem, then this 32MB limit is not the partition table, instead a physical problem with the drive. If so, just throw it out. Don't trust it. I just had to throw out a 4gig. It sucks. –  bambuntu Feb 18 '12 at 8:29
    
A way to maintain these drives best is not allow writing too much in the same area. Think of it this way, if you write a file, then delete it, it's probably going to write the next new file in that same spot. Repeatedly doing this wears out that general area. If you only trash the file, it doesn't remove it, just marks it. So let the trash fill up until you have no space left. –  bambuntu Feb 18 '12 at 8:38
    
dd: writing to `/dev/sdb': No space left on device 62689+0 records in 62688+0 records out 32096256 bytes (32 MB) copied, 0.109729 s, 293 MB/s –  antubis Feb 18 '12 at 12:58
show 1 more comment

As much as this sounds like a hardware failure, a procedure that can be tried is:

  1. Begin by taking a disk image of whatever can be read from the device, using dd.

    $ dd if=/dev/sdX of=memory_card.img

  2. After, fill it with zeros, e.g. $ dd if=/dev/zero of=/dev/sdX, then reformat it.

share|improve this answer
    
I did take an image from it (dd noerror and ddrescue), and it was 32MB of zero. There wasn't a single byte of anything else. I'll try writing in case it has a different effect but that 32 seems to have become a physical limit. –  antubis Feb 17 '12 at 13:38
    
I should clarify, that was with if=/dev/sdb –  antubis Feb 17 '12 at 13:51
    
Then yes, it most likely is a hardware problem. –  Renan Feb 17 '12 at 18:06
add comment

I've run across cards in that condition a couple of times. I'm sorry to report that I've not been able to fix any of them. I'm thinking it's probably due to a hardware failure as no software tricks I could think of could get them going again.

share|improve this answer
    
I expect you're right there. A shame, but thanks. –  antubis Feb 16 '12 at 21:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.