Recovering an SD / microSD card that is no longer mountable

November 08, 2018

Recovering an SD / microSD card that is no longer mountable

The other day we managed to zap one of our Raspberry Pi's microSD cards.  This was our own fault; for months the Pi had been crashing due to a segmentation fault.  We never got around to finding the root cause, and suddenly the Pi would no longer boot.

In the past, I would normally just give up on the card and start over again, however in this case, we had put a lot of time into this particular image.

So, I got to work trying to figure out how to recover the SD card.

We tried many things, but here is what actually worked!

We put the SD card into a reader and inserted it into a working Raspberry Pi. Running sudo fdisk -l listed the partitions on the system.  In this case, sdc was the bad SD card.  

Device     Boot Start     End Sectors Size Id Type

/dev/sdc1        8192    93814    85623 41.8M  c W95 FAT32 (LBA)

/dev/sdc2       94208 15523839 15429632  7.4G 83 Linux

We tried mounting sdc2, using sudo mount /dev/sdc2 /mnt,   and this resulted in a Bad Superblock error.  Without getting into details, this means that the database on the SD card of all the stuff on the SD card was damaged

Fortunately, Linux is smart enough to create backup superblocks!

To find the backup superblocks, we ran mke2fs -n /dev/sdc2.  

There were were a few backups superblocks, but the one we used was 32768

To restore, we ran sudo e2fsck -b 32768 /dev/sdc2

When running, many errors came up and we just chose the default options.  You might consider running e2fsck with the -a option, which ignores all errors and attempts to automatically fix them.  Only do this if this is an option of last resort.

When e2fsck was done, we were able to mount the drive, proving that miracles DO happen.  We have not tried to boot using this SD card, nor do we plan to.  My goal was to recover some files and put them on our new system, which is running off a USB drive instead of SD card.


Leave a comment

Comments will be approved before showing up.

Also in News

The Raspberry Pi Pico
The Raspberry Pi Pico

July 28, 2021

Raspberry Pi Pico’s are a great microcontroller that has a fair amount of range, despite the slightly more tricky set up process, once it’s ready to go there’s a lot you can do. 

Continue Reading

Raspberry Pi Troubleshooting

June 30, 2021

Continue Reading

An introduction to soldering
An introduction to soldering

June 08, 2021

Soldering is a good skill to learn and improve throughout your making and DIY-ing, there’s quite a few situations where it will be the best option for a more permanent build.

Continue Reading