[Android Software/Hacking General [Developers Only]] amarullz:
Introducing....

AD2SDX - AMARULLZ DATA TO SD-EXT

by amarullz [at] yahoo [dot] com

* Oct 20 2011 (ALPHA02) - Update Compatibility

* Oct 19 2011 (ALPHA01)

WHAT IS IT??

This mod will move all Internal Memory (data) into sd-ext,

"but not like data2ext"

, this mod will maintain the performance, because it still place dalvik-cache and system application data in Internal Memory.

HOW IT WORK??

The script will do this in the first boot:

Move Mounting Internal Memory (/data) Into /sd-ext

Mount SDCard-Ext (mmcblk0p2) partition into /data

Create dalvik-cache directory in Internal Memory data (/sd-ext), and symlink it to mmcblk0p2 (/data)

Create data directory in mmcblk0p2 (/data) And symlink it into Internal Memory data (/sd-ext)

Create symlink of app, app-private, app_s and lib_s from mmcblk0p2 (/data) to Internal memory data (/sd-ext)

Create symlink for all non-symllink of Internal Memory data (/sd-ext) into mmcblk0p2 (/data)

After Initializing Setup (First Boot), reboot the system (Just reboot, don't go into recovery), the mod will automatically do this following:

Create data_s in Internal Memory data (/sd-ext)

Move All mmcblk0p2(/data)/data/com.htc* and com.android* into Internal Memory data(/sd-ext)/data_s

Create symlink all files/directory from Internal Memory data (/sd-ext)/data_s/* into mmcblk0p2(/data)/data/ So the System Application Data still read into Internal memory, but rest Application Data will read Into SDCard.

ILLUSTRATION

​

INSTALLATION

For now, use adb shell and Install it manually, I am android newbie :D, still unfamiliar with recovery zip installer.

Delete Any A2SD Script in /system/etc/init.d ( common name was 40a2sd )

Copy 40ad2sdx into /system/etc/init.d Don't forget to chmod 755/777 it

Reboot ( 2x optional )

INSTALLATION WITH ADB IN RECOVERY MODE

C:\>adb shell
# mount /system
# exit

C:\>adb push 40ad2sdx /system/etc/init.d/

C:\>adb shell
# cd /system/etc/init.d
# rm 40a2sd
# chmod 755 40ad2sdx
# cd /
# umount /system
# exit

C:\>

NOTE: the "rm 40a2sd" should be the name of app2sd init.d file.

NOTE

If you install it after clean flash you need to reboot your phone at the 1st boot to activate System App Data on Internal Memory.

CAUTION!!!

YOU SHOULD UNZIP AND MANUALY COPY THE FILE INTO /system/etc/init.d/ - THE ZIP FILE WASN'T AUTO INSTALLER THAT CAN BE RUN IN RECOVERY!!!!

WARNING!!!

THIS MOD ONLY IN TEST STAGE, ONLY ADVANCE USER I SUGGEST TO TRY THIS SCRIPT.

I DON'T TAKE ANY RESPONSIBILITY IF YOU BROKE/BOOTLOOPS YOUR SYSTEM/ROM/PHONE.​

TESTED-DEVICE / ROM

HTC Desire (Bravo)

- Cool3D RunnyMede Sense 3.5 v2, v3

- Cool3D AceS Sense 3.0 v3, v4

If You Already Test it and works,.. Please send me a feedback in your comment...

LOGS

VERSION 1.0 ALPHA02
===================
* Add framework_s into strict mmcblk0p2
* Add Create symlink for rest non-symlink files from mmcblk0p2 to mtdblock5 ( Hope will fix bootloop )
* Change loop method from `ls -d *` to `ls -a` ( may fix error on .systemapp and all file with dot name at first char )

VERSION 1.0 ALPHA01
===================
* Initial Release
* Support for clean flash or already running system
* com.android* and com.htc* set as System App Category
* dalvik-cache on Internal Memory
* add umount /sd-ext in first command

SCRIPT: ALPHA01

#!/system/bin/sh
#
# AMARULLZ DATA TO SD-EXT MOD FOR ANDROID ( AD2SDX )
# ==================================================
#
# by amarullz [at] yahoo [dot] com
# xda-developers : amarullz
# (c) 2011
# * Oct 19 (ALPHA01)
#
# Info: ~ For Changing Log
##

###
# Initializing
###

#-- SDCard Speed Fix
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
then
/system/xbin/echo "8192" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
fi;

#-- Unmount /sd-ext if it already mounted
busybox umount /sd-ext;

#-- Mount /data and move it to /sd-ext
busybox mount /data;
busybox mount --move /data /sd-ext;

#-- Mount sd-ext to /data ( You Will Get 1GB/2GB Internal Memory :D )
busybox mount -t ext4 -o noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p2 /data;
busybox chown 1000:1000 /data;
busybox chmod 771 /data;

###[ SDEXT mmcblk0p2 STRICT ]###
# app, app_s, lib_s, app-private, data : should in /data (mmcblk0p2)
#
# ~ ALPHA02 - Add framework_s into (mmcblk0p2) strict
###
for i in framework_s app app_s lib_s app-private data;
do
#-- If Symlink in /data, delete it
if [ -h /data/$i ]
then
busybox rm /data/$i;
fi;

#-- If Directory Exists in /sd-ext, move it to /data
if [ -d /sd-ext/$i ]
then
busybox mv /sd-ext/$i /data/;
fi;

#-- If Directory Not Extst in /data, create it
if [ ! -d /data/$i ]
then
busybox mkdir /data/$i;
#-- Just Open All Permissions ;)
busybox chmod 0777 /data/$i;
fi;

#-- Now Create Symlink From /sd-ext to /data
if [ ! -h /sd-ext/$i ]
then
busybox ln -s /data/$i /sd-ext/$i;
fi;
done;

###[ INTERNAL mtdblock5 STRICT ]###
# For performance, dalvik-cache should be on /sd-ext
###
for i in dalvik-cache;
do
#-- If Symlink in /data, delete it
if [ -h /sd-ext/$i ]
then
busybox rm /sd-ext/$i;
fi;

#-- If Directory Exists in /sd-ext, move it to /data
if [ -d /data/$i ]
then
busybox mv /data/$i /sd-ext/;
fi;

#-- If Directory Not Extst in /data, create it
if [ ! -d /sd-ext/$i ]
then
busybox mkdir /sd-ext/$i;
#-- Just Open All Permissions ;)
busybox chmod 0777 /sd-ext/$i;
fi;

#-- Now Create Symlink From /sd-ext to /data
if [ ! -h /data/$i ]
then
busybox ln -s /sd-ext/$i /data/$i;
fi;
done;

###
# Now create symlink of the rest non Symlink Directories and Files on /sd-ext to /data
#
# ~ ALPHA02 - Fix ls to ls -a, it's ok, because we test -h for symlink
###
cd /sd-ext;
for i in `ls -a`;
do
if [ $i != ".." -a $i != "." ]
then
if [ ! -h /sd-ext/$i ]
then
if [ ! -h /data/$i ]
then
busybox ln -s /sd-ext/$i /data/$i;
fi;
fi;
fi;
done;
cd /;

###
# It should also need to create the rest non Symlink Directories and Files on /data to /sd-ext
# ~ ALPHA02 - Some Directory may be missing if we don't use it
###
cd /data;
for i in `ls -a`;
do
if [ $i != ".." -a $i != "." ]
then
if [ ! -h /data/$i ]
then
if [ ! -h /sd-ext/$i ]
then
busybox ln -s /data/$i /sd-ext/$i;
fi;
fi;
fi;
done;
cd /;

###
# Now Important Thing, is to move the com.htc* and com.android* data to /sd-ext (internal)
# For Good performance. So the system applications will run smooth.
#
# System application will read/write in Internal memory, and 3rd apps will run on sdcard
#
# Notice: Will be affected in 2nd boot :D, so Reboot the system after 1st boot...
###

#-- Prepare data_s in /sd-ext ( For system data )
if [ ! -d /sd-ext/data_s ]
then
busybox mkdir /sd-ext/data_s;
#-- Just Open All Permissions ;)
busybox chmod 0777 /sd-ext/data_s;
fi;

#-- Now Move All com.htc* and com.android* to Internal Memory
cd /data/data/;
for i in `ls -d com.htc* com.android*`;
do
#-- Only Non Symlink
if [ ! -h /data/data/$i ]
then
busybox mv /data/data/$i /sd-ext/data_s/;
fi;
done;

#-- Create Symlink of /data/data_s/* to /data/data/ (mmcblk0p2)
cd /sd-ext/data_s/
for i in `ls -d *`;
do
#-- Only If Symlink Not Exists
if [ ! -h /data/data/$i ]
then
busybox ln -s /sd-ext/data_s/$i /data/data/$i
fi;
done;

#-- Of Finished.... :D

INSTALL ZIP FROM RECOVERY?

Thanks to tezgomet ;) -- Download Attachment by tezgomet >>

KNOW BUG

Titanium Backup - Restore the Application Data ( com.android*/com.htc* data )