fix your G1 Android messed up SD card
I recently purchased one of the new T-Mobile G1 Android phones, and not a few hours had passed and I had run into a brick wall – the SD card would not mount on my Linux laptop, I was getting all sorts of random read errors. A little Googling showed me I wasn’t alone, it appears many, many people have gotten SD cards with their G1 having the same type of issue. Here’s how you can fix it with a card reader (not the phone), any linux distro and ‘parted’ partitioning tool.
The below looks difficult and long, but in reality it takes all of 5 minutes to fix. It’s taken me longer to write this out than it did to do the actual process – I’m writing it from memory in fact. I did the below to two different SD cards that were failing to function properly and now they’re fine.
NOTE: please, be sure you’re working on the SD card and not your hard drive, mmmk?
Step 1: power off the phone and remove the microSD card from the slot. Now insert this microSD chip into one of the larger SD cards (this did not come with the phone – I have a bunch of these from other microSD cards, if you don’t have one I’m sure one of your coworkers does).
Step 2: insert the SD card into a reader, and if you’re lucky it will mount fine – mine did. This allowed me to copy off all the pre-loaded content that T-Mobile had given me, but really isn’t that important. If the card doesn’t mount then you really can’t do this part. Make sure to unmount the card before proceeding.
Step 3: figure out the linux block device name of your card; this will depend on the card reader you have – there is no one name I can give you. In my case I was using a builtin reader in the laptop, the device was /dev/mmcblk0p1 – in many cases it will show up as a scsi disk such as /dev/sdc or something. How you get this info easily is one of two ways — if the card mounted, then just type “df -h” and it’s listed right there. If it didn’t mount in the above step, then look at /var/log/messages to get the name the linux kernel gave to this device.
Step 4: start ‘parted’ with the name of this device *without* the partition name. If the ‘df -h’ above gave you /dev/sdc1, then you remove the ’1′ (partition) and the device itself is /dev/sdc. In my case, the system put a “p1″ on the end which I removed which left me with /dev/mmcblk0. I started parted then like so:
Step 5: after ensuring you’re actually using the SD card (check the output, type ‘print’ to be sure, whatever — just don’t go screwing with your computer’s hard drive OK? :) ) type the command “mklabel”. The parted tool will warn you that you are about to destroy the content, say Yes. Then it will ask you for the name of the label – type “msdos” as that is the proper answer for this SD card.
Step 6: type “print” to show the partition table (it will be blank), what you’re looking for is the size of the card as parted sees it. This is a line that looks like:
Disk /dev/mmcblk0: 2045MB
Step 7: type the appropriate ‘mkpartfs’ command using the above disk size to make it one single big fat16 partition, like so:
mkpartfs primary fat16 0 2045MB
Tip: type “print” again and it should show one partition taking the whole disk.
NOTE: if your SD card is larger than 4GB use fat32 above instead of fat16. The FAT16 format can only handle up to 4GB (w/ Windows NT/2000/XP/+) for technical reasons; you will need to use fat32 on larger 8GB/16GB/etc. SD cards.
Step 8: type “quit” to leave parted.
Step 9: type “mkfs.vfat /dev/mmcblk0p1″ (or /dev/sdc1, or whatever the proper device name is of your block device and partition you just made) to quickly make the filesystem on it.
Step 10: mount the SD card (just take it out and stick it back in in most modern Linux like Fedora or Ubuntu) and copy the old content back onto the card, if needed.
Now you can stick that card back into your phone and it will work correctly for not only mounting as an SD card with your Mac/PC, but also the forced updating and other tricks that seemed to have failed will (or should) now work. The basic problem is the SD cards are being made without a proper partition table, and this seems to have some sort of off effect with the Android OS.
2008-11-13: If anything is unclear, please feel free to leave a comment – I see a lot of people are making their way to this post from various websites and Google searches, the problem is widespread. Feel free to pass on this info to other G1 Android sites, let’s get the knowledge out there and circulating.