Thursday, March 22, 2012

Android: Copying SD cards

Switching SD cards in your phone and copying the contents of the old to the new one can cause trouble if permissions aren't right. This usually happens if your "middle man"  is not using FAT file system. This is how I solved it (note; using 775 permissions can cause security issues!).

* Mount the SD card on a Linux machine through our phone or using a card reader.
* Copy the contents of the SD card to a temporary location on your machine
* Set permissions (recursively) to 775 (rwxrwxr-x) on the contents (chmod -R 775 /tmp/sdcard)
* Unmount SD card and mount the new one
* Copy the contents from the machine to the new SD card
* Unmount the SD card

Couple of tips:
* Don't switch SD cards while Android is running, especially not if you have apps or app data on the SD card
* ClockworkMod can mount the SD card as USB storage
* If you have CWM backups, try and open the "Restore" after the copy procedure. If your backups are listed your SD card is most probably good to use
* Again, don't switch SD cards when Android is running

Following these steps a 2GB card was successfully replaced with a 16GB without any application issues.

I am not responsible for any loss of data or damaged SD cards or phones.