Skip to content

Instantly share code, notes, and snippets.

@sarim
Forked from anonymous/README
Last active December 10, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarim/4494738 to your computer and use it in GitHub Desktop.
Save sarim/4494738 to your computer and use it in GitHub Desktop.
This script copies all data from /data/data to any directory(in sdcard) and (soft)links back them in /data/data.

This script copies all data from /data/data to any directory(in sdcard) and (soft)links back them in /data/data.

The purpose is to free space from /data/data.

To use it, first make sure the DESTDIR exists, change it according to your need, mkdir it. here i used /data/sdext2 which is a ext partition on sdcard mounted by link2sd.

make sure your android is rooted and you have cp,rm,ln binary installed, usually these come from busybox.

copy the script to android,

adb push linkappdata.sh /sdcard/

now goto shell,

adb shell

become root,

su

now run it,

sh /sdcard/linkappdata.sh

wait till it finishes.

Run the last command again if you install a new app.

#!/system/bin/sh
cd /data/data
DESTDIR=/data/sdext2/skdata/
for DIRS in `find . -mindepth 1 -maxdepth 1 -type d`
do
cp -rp $DIRS $DESTDIR/
rm -r $DIRS
ln -s $DESTDIR/$DIRS $DIRS
done
echo finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment