I Love Android; It Hates My SD Cards

Sometimes, especially in the tech community I belong to, I feel like the last lone non-Apple guy.  I don’t own a MacBook, I don’t own an iPhone and the iPads are for the kids to play games on.  I own two Windows-based laptops, a gorgeous original Voodoo/HP Blackbird gaming machine, six Android phones (HTC Evo, Samsung S2, two Samsung S3s, Note 2, Note 3), a Windows phone (Nokia Lumia 920) and a Samsung Tab 2.0 7” tablet.  My glasses aren’t too rose-colored though, as I admit each of them have their quirks.

The Android Lineup

One of the consistent issues I have with Android is that it’s extremely quick to trash the file system on the SD cards that are used for additional, external storage.  So much so that I’ve come to the point where I don’t rely on them for much of anything critical.

Tonight, for example, I had another card (32Gb Lexar Class 10 Micro SD) fail.  I shut the phone off cleanly, swapped the battery for a new one (all the iPhone users just either got a puzzled look on their faces or sighed longingly), and powered the phone back on.  After the Android OS started, I got a message that I’ve, unfortunately, seen before:

“Damaged SD Card. SD card is damaged.  Try reformatting it.”
BadSDCard

Wonderful.  Time to figure out the damage.  What on earth does Android store on the SD card anyway?

First, the good news: most of the data on the SD card is related to media storage, and by default almost everything is going to be written to the internal storage of the phone.  With even the most budget-minded phone having tens of gigabytes of internal storage, the external SD card really is optional.  If you haven’t specifically told the phone to store media there, it won’t.  And maybe you didn’t lose anything significant.

But, if you are like me, you’d pointed lots of things to the SD card, like:

  • Pictures and Video taken with the phone
  • Pictures attached to MMS messages and other messaging clients
  • Cached music from Google Play and other services
  • Downloads from the internet
  • Videos and Movies (the 5.7in screen on the Note 3 is just big enough to be useful for this)
  • eBooks

So, what to do?  First, as with any damaged media don’t try to write any more data to it! Take the SD card out of the phone immediately.

Next, connect it to your PC/laptop with an adapter, and see if you can read the file system.  I’ve seen instances where even though the phone can’t mount it, the FAT32 file system is viewable from Windows.  If that’s the case for you, copy everything off manually.  Once you have everything you can get, try using some of the Windows command line disk tools to repair the file system:

chkdsk /X /F <SD card drive letter>

I’ve seen this process result in a “clean” file system, but I’d recommend reformatting the card once you’ve gotten everything you can off and it’s back in the phone.  Your mileage may vary.

If the file system can’t be read, you’ll get a prompt that looks like this:

12-14-2013 2-02-44 AM

Because the file system can’t even be mounted, we’ll need something that works below the file system to recover any data.  One of my personal favorites is a free tool called Photorec.  It can be run on almost any OS, and has a nice, simple CLI interface.  Here’s a quick walk-through of how I went through the process to recover data from this particular card:

  1. Download the binaries to the PC that the SD card is connected to
  2. Run “photorec_win.exe” with administrative permissions
  3. Select the media you want to recover data from
    12-14-2013 1-55-11 AM
  4. Choose the partition you are interested in.  You also have the option to scan the entire physical disk if the partition table is borked
    12-14-2013 1-55-22 AM
  5. Once you’ve chosen the partition, tell Photorec what kind of file system it’s looking at.  For Android, that’s always FAT32, so choose “Other”
    12-14-2013 1-55-41 AM
  6. Now, choose to recover from the “Whole” partition
    12-14-2013 1-55-50 AM
  7. Finally, choose the directory you want to write the recovered files to, and hit “C” to get started
    12-14-2013 1-56-10 AM
  8. On my 32Gb disk, it took about 40 minutes to scan the entire partition and recover close to 1,000 files.
    12-14-2013 1-30-00 AM

Just out of curiosity, I tried both a “WHOLE” and a “FREE” recovery, and the “FREE” did find about 50 more files.  I suggest you try both, and maybe even run a couple recovery scans to get everything the software can find.

Once I’m comfortable that I’ve got everything off the card that’s coming off the card, it’s time to see if it’s able to be salvaged.  Head into your settings, choose “Storage” and go ahead and format the SD card using the button at the bottom of the screen.  Obviously, this kills everything on the card, so make sure that you have everything you need.  Some people (ahem) just go buy a new one and keep all the “damaged” ones in a box just in case there’s something I missed later.  But I have well documented data protection and retention issues…

FormatSD01FormatSD02

As you can tell, I’ve been through this process a couple times.  From a data protection standpoint, I use a cloud service storage (I’ve used both Dropbox and Syncplicity) to mirror the relevant folders for eBooks, videos and movies.  That way, if I have to reformat an SD card I can just re-copy over the data, no issues.  The Google Play data has to manually re-sync, which is a pain in the ass, but not the end of the world.

For the pictures and video, there are lots of options to do real-time backups.  Dropbox has a good one, but I use the native Android/Google+ auto-backup.  For me, since all of our family image backup/sharing is done on Picasa anyway, it means everything can be in one place, plus it’s free and works well.

Have you had issues with SD cards in Android?  Do you have a process that you’ve used to recover data from an SD card?  Comments and discussion are welcome below!