I have a 4GB SD card with some family pictures on it that I need to recover. When I insert the card into my card reader, it shows up as an unknown 32MB device (as /dev/sde) and cannot be mounted. When inserting back into the camera (a Nikon D60), it says the cards needs to be formatted (as does inserting it into a Windows machine). I want to recover all of the pictures on the card (there were others before the family pictures) because I don't know how many I took or their exact sizes (but I believe they were all JPEGs). The card should be formatted as a FAT32 filesystem.

What Linux or Unix utilities are available to recover the files? Can I do it myself or do I need to seek professional help?

Edit: It appears that my card reader has damaged the card in some way, making it unreadable and and unformattable. When I checked another card that was the exact same (save for no files), it "ruined" the second one. I would like to use the second card again, so is there a tool to format a damaged card that doesn't know (or cannot report properly) how large it is?


First, from your experience with the second card, it seems that your reader is damaged and now damages the cards you insert into it. Stop using that reader immediately, and try to recover the card with another reader. If your data is at all valuable, try to get a brand-name reader with better quality than a bottom-price one.

If the card is merely partly unreadable and not completely unreadable, first try to copy what you can from the card to an image file. Don't use dd for this as it'll stop reading on the first error. Use tools such as dd_rescue or ddrescue. Both tools try to grab as much data as possible from the disk. Example usage (/dev/sdc being the device corresponding to the card; if you don't know which one it is, run cat /proc/partitions and pick the one that seems to have the right size):

ddrescue -dr3 /dev/sdc card.image logfile

Since it looks like the filesystem structure is damaged (your OSes offer to format the drive because they don't see a valid filesystem on it), you'll have to try to recover the files individually. Fortunately, image files start with a recognizable header, and there are many existing carving tools that recognize images: Foremost, MagicRescue, PhotoRec (from the makers of TestDisk), RecoverJPEG, …

Most of these tools are available on typical unix distributions. But if you prefer, you can run a special-purpose distribution or other live CD including recovery tools such as SysRescueCD, Knoppix, CAINE

  • I think most of my troubles stem from the cards being recognized as only 32MB, when they should be 4GB. And I have no way of telling what the low-level cylinders, heads and sectors are. – user6148 Jun 7 '11 at 23:49
  • 2
    @Tyler: If your card isn't recognized at the right size by the hardware, replace the reader immediately. If you tried copying the image and the copy stopped due to errors after 32MB, try again with a tool like ddrescue. You don't need to know anything about cylinders/heads/sectors. – Gilles Jun 8 '11 at 0:02

I'd recommend TestDisk. I've used it successfully to recover files from corrupted hdd's. I normally use a distribution like TRK or SystemRescueCd.


PhotoRec from http://www.cgsecurity.org/ - free, open source, easy to use. Just recovered loads of family photos and videos from a corrupt SD card. Simply unzip into a folder, run the file and point it to the drive.


You have not detailed on how data got lost. If it is a logical deletion, and device has not seen much writing, chances of recovering data are good: the obvious advice is to go for TestDisk & Photorec. Of course, the traditional recommendation: write protect the original device, anyway, expose it to the least possible interaction. Best of all, dd it on some different support, unplug it and work on the image file. If, on the other hand, `bad' in the subject means physically ruined, things get tougher, but you should try all the same, because usually a minor portion of the blocks get unreadable. Especially on SD, which have a reputation of very high endurance.

  • I'm not sure how, but the card doesn't seem physically damaged. And I'm not very familiar with dd, so how might I recover the image of the card? What specifically would I need to do with the image? – user6148 Jun 7 '11 at 17:33
  • Try to find a reliable way to connect the sd to a pc. Suppose you manage and the raw device is mapped onto block device /dev/sda (use dmesg to know its name). Then do dd if=/dev/sda of=/mnt/hda1/image.dd bs=1M where /mnt/hda1 is the mountpoint of some other support large enough. Then unplug the sd, do a copy of image.dd and work on the latter so you don't have to replug the SD. See TestDisk step-by-step guide on its homepage. Hopefully from what you say it sounds like you just have to restore partition table/mbr. Good luck. – user495100 Jun 7 '11 at 18:29
  • 1
    @Tyler: Don't use dd, as it stops on the first error. Use something like ddrescue. – Gilles Jun 7 '11 at 22:53

I used photorec which comes in the package testdisk. It worked fine for me to recover photos from a sandisk microsd that was corrupted by my phone.

  • 1
    Can you, at least, provide links and documentation to flesh out your answer a bit? – HalosGhost Oct 7 '14 at 17:21

protected by Community Jan 11 '15 at 21:14

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?