Wiping Cache/Dalvik/Data

Death259

Senior Member
Nov 15, 2010
646
303
0
I'm wanting to write some edify code to wipe data, dalvik and cache. I think i've got the right idea for data and dalvik, but I'm not certain on cache.

Here's my following code for data and dalvik wipe. Is this the standard for wiping data? Do i need to delete everything from data and not just in the app directory?
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p37", "/data");
delete_recursive("/data/app");
delete_recursive("/data/dalvik-cache");
unmount("/data");
Also, i'm going to assume i can mount the cache, but i didn't know the block to mount it.

Any help would be greatly appreciated.

Edit: Thanks to this post, i was able to figure out the block i needed for cache. I would still like to know if this is the proper way of "wiping" the data, cache or dalvik-cache. Should i be formatting instead?
 
Last edited:

esgie

Senior Member
Feb 17, 2013
333
176
43
I'm not very familiar with edify, so I may be wrong, however I'll try to help by pointing some issues you may find when investigating this subject.

First look on the code above ... In general, it seems to be ok. Btw I can see that you are not trying to wipe /data but /data/app only...

To fully wipe data partition you shall run delete_recursive("/data"); and after that no additional dalvik-cache wipe will be necessary, as it lies on data so it will be deleted along with it.

Instead of recursive files deletion you may try format command or even some variation of mke2fs... it will create completely new filesystem instead of performing large amounts of delete i/o operations on the old one, along with not deleting filesystem stats, etc.

Hovewer, you have to know that running delete_recursive("/data"); or even format("/data") or something similiar seems to be not the best idea - be aware that real location of files from /sdcard is /data/media which is then bound with FUSE driver to /sdcard during the boot, so it acts like an sd memory BUT it still lies along with all your "regular" data files on /data partition. Doing such a recursive deletion will result in losing not only files from /data, but also from /data/media = /sdcard, which is probably not the thing we want to happen ;]
You may want to figure out how to avoid this, as you may lose the data which you didn't want to lose (for example: nandroid backups, if you keep them on /sdcard)! I personally don't know the exact solution and don't have time and possibility to figure it out at the moment

Also, please be aware that Android has the "wipe" command built-in, put "wipe" in terminal emulator to find out the syntax. I am not sure but it may avoid the sdcard when wiping automatically, as it is native android tool and it may be adapted for Android's file stricture.

Last but not least, you can find out device-partition pairs by inputting such a command via terminal or adb shell (seeking for a device name which is mounted as /cache in example below):
Code:
cat /proc/mounts | grep cache
 

Death259

Senior Member
Nov 15, 2010
646
303
0
I'm not very familiar with edify, so I may be wrong, however I'll try to help by pointing some issues you may find when investigating this subject.

First look on the code above ... In general, it seems to be ok. Btw I can see that you are not trying to wipe /data but /data/app only...

To fully wipe data partition you shall run delete_recursive("/data"); and after that no additional dalvik-cache wipe will be necessary, as it lies on data so it will be deleted along with it.

Instead of recursive files deletion you may try format command or even some variation of mke2fs... it will create completely new filesystem instead of performing large amounts of delete i/o operations on the old one, along with not deleting filesystem stats, etc.

Hovewer, you have to know that running delete_recursive("/data"); or even format("/data") or something similiar seems to be not the best idea - be aware that real location of files from /sdcard is /data/media which is then bound with FUSE driver to /sdcard during the boot, so it acts like an sd memory BUT it still lies along with all your "regular" data files on /data partition. Doing such a recursive deletion will result in losing not only files from /data, but also from /data/media = /sdcard, which is probably not the thing we want to happen ;]
You may want to figure out how to avoid this, as you may lose the data which you didn't want to lose (for example: nandroid backups, if you keep them on /sdcard)! I personally don't know the exact solution and don't have time and possibility to figure it out at the moment

Also, please be aware that Android has the "wipe" command built-in, put "wipe" in terminal emulator to find out the syntax. I am not sure but it may avoid the sdcard when wiping automatically, as it is native android tool and it may be adapted for Android's file stricture.

Last but not least, you can find out device-partition pairs by inputting such a command via terminal or adb shell (seeking for a device name which is mounted as /cache in example below):
Code:
cat /proc/mounts | grep cache
Thanks a bunch! I didn't even think about the sdcard getting wiped...
 

Ricky Divjakovski

Recognized Developer / Recognized Contributor
Feb 4, 2013
5,214
7,595
263
25
Sydney
=Death259;48255914]Thanks a bunch! I didn't even think about the sdcard getting wiped...
What you can do is extract and call a bash script and recursively remove all content from /data excliding the media folder (sdcard)
Also dalvik is in /data already so wiping data automatically wipes dalvik :)
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone