Thursday, June 24, 2010

Ubuntu: Fixing "Damaged Android SD Card"

Android suddenly started telling me that my SD card was "Damaged".  To fix that in Ubuntu, just mount the card and run the following:
sudo fsck -a /dev/sdb1

The /dev/sdb1 part may be different.  To find out, just type dmesg and see the sdb:sdb1 in the output:
[12330.974901] sd 11:0:0:0: [sdb] Assuming drive cache: write through [12330.974911] sdb: sdb1 [12330.995285] sd 11:0:0:0: [sdb] Assuming drive cache: write through [12330.995289] sd 11:0:0:0: [sdb] Attached SCSI removable disk

7 comments:

  1. Thanks David Ron. I thought it was funny that I could see everything just fine in Ubuntu, and figured there must be some command to fix it.

    ReplyDelete
  2. Apparently Android is really picky about any files with illegal file names. I had this problem after copying some mp3's over to my SD card and couldn't get rid of the problem until I deleted the files and cleared the trash bin.

    ReplyDelete
  3. Will the files in SD card be erased?

    ReplyDelete
  4. The files on the card are left mostly intact, although since the card is damaged in some way, files in the damaged area will be irrecoverable. The irrecoverable files will only be partially recovered and may become useless. In my experience, there will be some lost data, but most of the data will be fine.

    Always backup your crucial data.

    ReplyDelete
  5. David --

    Lately, I've found that fsck needs both -w and -r, or it will leave the filesystem unchanged. So I did:

    sudo fsck.vfat -w -r /dev/sdc1

    Replace sdc1 with your block device. For a FAT32 file system, fsck, dosfsck, and fsck.vfat are equivalent.

    midbie: This operation shouldn't remove files in the normal case -- except ones that are probably already too corrupt to be used anyway. copy what you can before you fsck. I mount the filesystem and do:

    rsync -av /media/sdcard ~/backups

    Replace "/media/sdcard" with wherever it's mounted. If the directory ~/backups doesn't exist, it will be created, and the contents of your sdcard copied to a subdirectory called "sdcard".

    Write me if you have any questions.

    -- Patrick

    ReplyDelete
  6. Thanks David, your single command worked flawlessly!

    It is much more easier than using adb shell, unmounting the data partition and running e2fschk.

    ReplyDelete
  7. I find this post about the SD card corruption. This command is very helpful to see the file system on that drive in Ubuntu. If any bad sector arises then fix it with this command-

    sudo dosfsck -t -a -w /dev/sdb1

    fsck.vfat -r /dev/sdXn


    Try these commands, these are very helpful.

    ReplyDelete

AddThis

Bookmark and Share