Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Sometimes my SD card gets "corrupted" and this leads to many read/write errors. Usually, connecting the SD card to the windows 7 and selecting the "Error Checking" (Right click the drive > Tools > Error Checking) option finds the corruption and fixes it.

Is there any tool or app for checking SD cards for drive errors and fixing the same from within the android itself?

I'd also like to mention that I'm on rooted froyo with busybox installed.

share|improve this question
    
Have you tried with a terminal app, doing a su and running the /system/bin/fsck.exfat? –  Izzy Jan 31 '13 at 15:58
    
@Izzy Gives me No such file or directory –  Power-Inside Jan 31 '13 at 16:06
    
Check different locations, maybe it's in /system/xbin instead? Try cding into the directory, and ls fsc* to check what's available. Must be somewhere :) –  Izzy Jan 31 '13 at 16:11
    
@Izzy Just typing fsck seems to run the binary. (shows Fsck (busybox 1.21.0-Stericson.. blah blah) I don't really know the syntax or anything much. I'm a windows user. So maybe you could post an answer below? –  Power-Inside Jan 31 '13 at 16:16
1  
Exactly. Busybox tries to be as slim as possible. Try aunt Google with "man mount", works fine :) And see my answer below. If something's unclear, comment there (or see me in chat -- though I won't be available there for the next few hours, there are still other knowing members to help you out :) –  Izzy Jan 31 '13 at 16:39
show 2 more comments

2 Answers

up vote 6 down vote accepted

You can fix this with the help of root and a terminal emulator (e.g. Android Terminal Emulator (or, alternatively, using adb shell). The binary to do the job is called fsck, and usually located in either /system/xbin or /system/bin. Sometimes you need a special variant of it, which might e.g. be called fsck.exfat or the like. So first let's make sure we find the right binary:

cd /system/xbin
ls fsc*

If not found, repeat with /system/bin. I will assume here it was found in the first place, and is simply called fsck (adjust the following correspondingly if that's not the case).

As fsck comes from the "Linux core", we can consult its man page for the syntax. Though there might be some options not working on Android, the most basic ones should. See the linked man page for details (or run a Linux VM and use man fsck in case that page disappears) -- I will stick to the basics here:

First we need to find the device your SD card is bound to. If it's mounted, the mount command will assist us:

mount

That's it, basically: Check the output and see where your SD card sits. Usually this is something using vold, but it's different between devices. Output may include something like /dev/block/vold/179:17 on /mnt/storage/sdcard -- in that case, the first part of my quote is our device. In order to repair the "drive", you need to unmount it first. This can be done via the settings menu, or, as we're just in the terminal, by issuing

umount /dev/block/vold/179:17

Now we can go for the repair job. Basic syntax is:

fsck [options] [-t fstype] <filesystem> [fsoptions]

So we first try the simplest approach and hope fsck figures out everything itself:

fsck -C -r /dev/block/vold/179:17

Which basically means: Show progress (-C), and always ask the user to repair (-r) any errors on /dev/block/vold/179:17. If this does not work out, check with the linked man page for further options.

share|improve this answer
2  
You can also save yourself the cd steps if you want by using ls /system/bin/fsc* and ls /system/xbin/fsc* from whatever your current working directory is. You could even combine the two into one command with ls /system/xbin/fsc* /system/bin/fsc*. –  eldarerathis Jan 31 '13 at 16:52
    
on some systems the command may also be named e2fsck, such as on my stock Australian Galaxy Nexus. –  Lie Ryan Nov 9 '13 at 11:14
    
@LieRyan Sure you don't confuse things? e2fsck is the file system checker for extFS. So if it has a different name, it's rather fsck.fat or fsck_msdos (the latter a real world example from an old 2.2 ROM off my Moto). –  Izzy Nov 9 '13 at 12:48
    
No, I don't confuse things, what I wasn't aware of is that this question is actually about SD card. So yeah, I actually did confuse some things. Well strictly speaking, you can format your SD card as ext as well, so that might apply to people that does that. –  Lie Ryan Nov 9 '13 at 12:57
    
Point taken. Though the "average user" (or the one "in doubt") might better stick with FAT, at least for interoperability. At least until ExtFS is supported on the majority of OSs easily and by default without additional drivers required (guess Windows is and will remain a pitfall here, as usual). –  Izzy Nov 9 '13 at 13:08
show 1 more comment

I've found an app on the market that can "Repair damaged sdcard and scan for bad blocks" etc.

https://play.google.com/store/apps/details?id=com.sylkat.AParted&hl=en

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.