roottools photo for stock recoveryA while back I had a root app start writing a backup to the internal SD card, and it didn’t stop until the entire free storage space of the internal SD card was completely written over with a bad backup.

It also managed to save it somewhere that I could not find with ES File Explorer, Windows Explorer, etc. What ensued was a game of me attempting to locate where the data was being incorrectly put so I could delete it.

Of course, with the entire contents of the internal SD card filled I couldn’t install any software from Google Play that might have helped me out with that, so I had to resort to some command line searching.

For this, assuming you can’t get something from the market installed due to being completely out of space, you’ll need either a terminal emulator or ADB to shell into the phone. I’m going to suggest ADB because keyboard + computer trumps spell checking keyboard that doesn’t understand Android command line commands and likes to offer creative fixes.

Your first step to determining what’s full is to execute in either a terminal or adb shell the command “df /sdcard” – this will display the disk space used by the internal SD. For purposes of this, the /sdcard mount point is all we’re interested in, but if you want to see external space used you could do “df /sdcard2”.

df usage

In this case, we see that the internal SD card has 11 gigs free. When I ran into this I had 0. It was not fun.

Generally you could also mount the device to a Windows/Mac computer, however it was not showing me the disk usage or folder info, basically I was staring at an old copy of the directory information because the media scanner had died I believe.

Anyway… once you’ve seen your disk usage, we’ll move on to figuring out what directory is taking up all the space.

Execute the command: “cd /sdcard”

Now that we’re in the internal SD card, we’ll execute the command “du -md 1” – this will display the directories and how many megabytes they’re using.

du usage

From there on out you should have enough information to locate what was taking up all your space. You might have to scroll around a bit and change directories into the folders that are taking up all the space to see what exactly the problem is, but in the subdirectories you can execute a “du -m” to locate the individual files by size.

After you’ve found what you want gone, delete via the “rm” command, eg “rm wasteofspace.mp4”.

It’s significantly easier to just delete a few photos and install an app that will show you everything on the drive, but sometimes knowing how to do these things when you’re without a data connection or any space whatsoever can be useful.

Just keep in mind, DCIM is where all your photos live, so you might want to go easy on the killing of that directory. Also keep in mind not all devices ship with df, du, etc installed. For these devices you’ll need something like Busybox installed in order to execute the commands, and then the format will be something like “busybox du -m”.