Repairing SD memory cards hosed by N800

Unfortunately my N800 still “eats” memory cards from time to time. It seems to be due to a corruption of the card’s partition table. Here are the steps I use to recover the cards. The example is for an 8 GB PNY SDHC card formatted with Ext2 filesystem. I used Kubuntu 7.10 Gutsy and TestDisk 6.6 for this.

  1. Do a backup of the card:
    # dd if=/dev/sdc of=/tmp/n800-8gb-SD-ext2.image conv=noerror
  2. Start the TestDisk utility for the corrupted card:
    # testdisk /dev/sdc
  3. Test the geometry of the card by selecting partition table type Intel and then Analyse. With my card, TestDisk would then display an error message: Partition sector doesn't have the endmark 0xAA55. The geometry is wrongly recognized as CHS 997 255 63 (CHS = Cylinders/Heads/Sectors) and no partition information is found in the subsequent scan.
  4. Determine the correct geometry by restarting TestDisk. This time choose partition table type Mac. It will display the correct geometry, in my case CHS 16015360 1 1. Now validate this by selecting Analyse and ignore the warning about Bad MAC partition table and the current number of heads per cylinder is 1. You should be prompted with a line for your partition. Press “P” to browse through the files on the partition. If you can see all your files now: felicitations, continue with the next step. If not: bad luck, I have no idea.
  5. Restart TestDisk with partition table type Intel and select Geometry. Enter the numbers you received in Mac mode before. Do not change the Sector Size! Navigate back to Analyse mode. This time, the scan yields a partition entry, and you may re-check by browsing the files. Then Proceed and Write the table back to the card.
  6. Remove and re-insert the card. It should mount ok now. Unmount and try a filesystem check to make sure everything is fine:
    # fsck.ext2 -n /dev/sdc

In theory it should be possible to do all these steps with the image file instead of with the memory card directly, then writing back the repaired image to the card in a final step. Unfortunately, I didn’t manage to create a mountable image file this way. When I try

# mount -o loop -t ext2 /tmp/n800-8gb-SD-ext2.image /tmp/rescue

with the corrected image file, I get this error message:

mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so


Leave a Reply

You must be logged in to post a comment.