Corrupt SD Card Recovery

A friend of mine came back from vacation where he had taken a lot of pictures. When he got back home a large part of his Micro SD card (exFAT partition) was no longer accessible so he missed a couple of weeks of his photos and videos. His Windows Operating System froze completely when it hit a rotten cluster during a file copy action. So we had to find another solution to get his files back.

The first step I tried was to get the data from the SD card via Linux with ddrescue. With ddrecue, you create and complete dump of the SD card (or the sdb1 partition only). So you can do the data recovery on the image file (backup1.img) and not on the already corrupted SD Card.

The command you can use is:

ddrescue -d /dev/sdb1 /media/thomas/backup1.img /media/thomas/backup1.mapfile

But Linux also had also trouble reading when I hit a bad cluster. The only thing I could do during the read issues was a physical disconnect of the USB adapter, reconnect the adapter and restart the ddrescue process. The reason of was that a dual SD card adapter was used:

Micro SD > SD > SD > USB

(spoiler ALERT!: Never use multiple adapters for data recovery!!!)

Because ddrescue has a mapfile it goes further where he was stopped the last time.

While debugging I wrote a simple loop that forced a “physical” disconnection of the USB adapter wait one sec and reconnect the devices without touching anything.

Source of the USBReset (fork)

This works but is a very very slow process. This will takes months to recover so I had to find another way.

## Steps to Prepare:
# lsusb check card reader and change the /dev/bus
# Start script in usbreset folder 
# Run as sudo
# mount disk (media / thomas)
while true
	echo "Let's try Again!"
	ddrescue -d /dev/sdb1 /media/thomas/4905eb31-1df4-49bb-bb75-ec4889641d20/backup1.img /media/thomas/4905eb31-1df4-49bb-bb75-ec4889641d20/backup1.mapfile
	sleep 1
	./usbreset /dev/bus/usb/001/004
	sleep 1

The funny thing is that it was Sinterklaas time and that my daughter had just received a vtech kiddy photo camera with a Micro SD to USB adapter included 😀

So I try new new adapter: Micro SD > USB and with success.

And after almost 15 hours the result 99.98% rescued rate 🙂

During my search for a solution I found some interesting articles:

Happy recovering!

Author: Thomas Faddegon

Do you like my posts and want to do something back? You can buy me a beer :)