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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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…
Method 2
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.
Method 3
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.
Method 4
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.
Method 5
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0