[Desire Android Development] booce:
Ok here goes

#!/system/bin/sh

#data2extV9.3 by ownhere

#real IO improve from v9.0 !!!!!

echo "cfq" > /sys/block/mmcblk0/queue/scheduler

echo 1 > /sys/block/mmcblk0/queue/rotational;

for i in 1 2 3 4 5;

do

echo "deadline" > /sys/block/mtdblock$i/queue/scheduler

echo 0 > /sys/block/mtdblock$i/queue/rotational;

done

echo "try data2ext"

BUSYBOX="/system/xbin/busybox"

if [ -e /dev/block/mmcblk0p2 ];

then

if [ ! -e /data/system/system.firstrun.finish ];

then

#/system/xbin/mkfs.ext4 -t ext4 -E stride=64,stripe-width=64 -b 4096 -m 0 -F -L userdata /dev/block/mmcblk0p2

/system/xbin/mkfs.ext4 -t ext4 -b 4096 -m 0 -F -L userdata /dev/block/mmcblk0p2

/system/bin/tune2fs -o journal_data_ordered /dev/block/mmcblk0p2

/system/bin/tune2fs -E hash_alg=tea /dev/block/mmcblk0p2

/system/bin/tune2fs -e continue /dev/block/mmcblk0p2

/system/bin/e2fsck /dev/block/mmcblk0p2

#if [ -e /dev/block/mmcblk0p3 ]; then

/system/bin/tune2fs -O ^has_journal /dev/block/mmcblk0p2

/system/bin/tune2fs -O ^huge_file /dev/block/mmcblk0p2

#fi

#$BUSYBOX rm -f /data/local/system.firstrun

fi

$BUSYBOX mkdir /mnt/asec/ext

/system/bin/tune2fs -l /dev/block/mmcblk0p2

$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 /mnt/asec/ext

$BUSYBOX chown 1000.1000 /mnt/asec/ext

$BUSYBOX chmod 771 /mnt/asec/ext

if [ ! -e /data/system/system.firstrun.finish ];

then

$BUSYBOX rm -rf /mnt/asec/ext/*

$BUSYBOX mkdir /data/system

$BUSYBOX chown 1000.1000 /data/system

$BUSYBOX chmod 771 /data/system

$BUSYBOX touch /data/system/system.firstrun.finish

fi

if [ ! -e /mnt/asec/ext/data2sd.finish ];

then

$BUSYBOX mount -t auto -o ro /dev/block/mmcblk0p1 /mnt/sdcard

echo "+++ Found Ext, but data2ext is not finished, so do it now, please wait... it is long.";

cd /mnt/asec/ext

$BUSYBOX unzip -o /mnt/sdcard/sd-ext-ownhere.zip

$BUSYBOX chown -R 1000.1000 /mnt/asec/ext/app

$BUSYBOX chmod 771 /mnt/asec/ext/app

$BUSYBOX chmod 644 /mnt/asec/ext/app/*

cd /data

cp -a * /mnt/asec/ext

cd /

$BUSYBOX rm -rf /data/app

$BUSYBOX rm -rf /data/app-private

$BUSYBOX rm -rf /data/dalvik-cache

$BUSYBOX touch /mnt/asec/ext/data2sd.finish

sync

sleep 1

$BUSYBOX umount /mnt/sdcard

fi

sleep 1

$BUSYBOX umount /mnt/asec/ext

sleep 1

/system/bin/e2fsck -y -v -f /dev/block/mmcblk0p2

echo "0" > /data/misc/screen_lock_status

$BUSYBOX chown 1000.1000 /data/misc/screen_lock_status

$BUSYBOX chmod 644 /data/misc/screen_lock_status

sync

sleep 1

$BUSYBOX umount /data

$BUSYBOX mkdir /mnt/asec/mtddata

$BUSYBOX mount -o nosuid,nodev,relatime /dev/block/mtdblock5 /mnt/asec/mtddata

#$BUSYBOX mknod /dev/loop0 b 7 0

#$BUSYBOX losetup /dev/loop0 /dev/block/mmcblk0p2

$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

$BUSYBOX mkdir /mnt/asec/extdata

if [ ! -e /data/data2sd.ext.finish ];

then

if [ -e /dev/block/mmcblk0p3 ];

then

echo "+++ Found mmcblk0p3, will use it for /data/data, create ext4 fs on it now..."

#/system/xbin/mkfs.ext4 -t ext4 -E stride=64,stripe-width=64 -b 4096 -m 0 -F -L extdata /dev/block/mmcblk0p3

/system/xbin/mkfs.ext4 -t ext4 -b 4096 -m 0 -F -L extdata /dev/block/mmcblk0p3

/system/bin/tune2fs -o journal_data_ordered /dev/block/mmcblk0p3

/system/bin/tune2fs -E hash_alg=tea /dev/block/mmcblk0p3

/system/bin/tune2fs -e continue /dev/block/mmcblk0p3

/system/bin/tune2fs -O ^has_journal /dev/block/mmcblk0p3

/system/bin/tune2fs -O ^huge_file /dev/block/mmcblk0p3

/system/bin/e2fsck -y -v -f /dev/block/mmcblk0p3

$BUSYBOX mount -t ext4 -o noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p3 /mnt/asec/extdata

$BUSYBOX mkdir /mnt/asec/extdata/data

$BUSYBOX chown 1000.1000 /mnt/asec/extdata/data

$BUSYBOX chmod 771 /mnt/asec/extdata/data

$BUSYBOX cp -a /data/data/* /mnt/asec/extdata/data/

$BUSYBOX rm -rf /data/data/*

sync

sleep 1

$BUSYBOX umount /mnt/asec/extdata

sleep 1

fi

$BUSYBOX touch /data/data2sd.ext.finish

fi

if [ -e /dev/block/mmcblk0p3 ];

then

/system/bin/tune2fs -l /dev/block/mmcblk0p3

/system/bin/e2fsck -y -v -f /dev/block/mmcblk0p3

#$BUSYBOX mknod /dev/loop1 b 7 1

#$BUSYBOX losetup /dev/loop1 /dev/block/mmcblk0p3

$BUSYBOX mkdir /mnt/asec/extdata

#$BUSYBOX mount -t ext4 -o noauto_da_alloc,commit=5,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p3 /mnt/asec/extdata

$BUSYBOX mount -t ext4 -o noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p3 /mnt/asec/extdata

$BUSYBOX mkdir /mnt/asec/extdata/data

$BUSYBOX chown 1000.1000 /mnt/asec/extdata/data

$BUSYBOX chmod 771 /mnt/asec/extdata/data

if [ -d /data/data ] && [ ! -h /data/data ]; then

$BUSYBOX cp -a /data/data/* /mnt/asec/extdata/data/

$BUSYBOX rm -rf /data/data/*

fi

if [ -h /data/data ] || [ ! -d /data/data ]; then

$BUSYBOX rm -rf /data/data

fi

#$BUSYBOX ln -s /mnt/asec/extdata/data /data/data

$BUSYBOX mkdir /data/data

sync

sleep 1

$BUSYBOX umount /mnt/asec/extdata

sleep 1

$BUSYBOX mount -t ext4 -o noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p3 /data/data

#$BUSYBOX mount --bind /mnt/asec/extdata/data /data/data

fi

if [ -e /dev/block/mmcblk0p4 ];

then

echo "+++ Found mmcblk0p4, will use it for swap, create swap fs on it now..."

$BUSYBOX mkswap /dev/block/mmcblk0p4

$BUSYBOX swapon /dev/block/mmcblk0p4

echo "1" > /proc/sys/vm/swappiness

echo "50" > /proc/sys/vm/vfs_cache_pressure

fi

sync

for i in system;

do

if [ ! -d /mnt/asec/mtddata/$i ];

then

$BUSYBOX mkdir /mnt/asec/mtddata/$i;

fi

$BUSYBOX chown 1000.1000 /mnt/asec/mtddata/$i;

$BUSYBOX chmod 771 /mnt/asec/mtddata/$i;

if [ -d /data/$i ] && [ ! -h /data/$i ];

then

$BUSYBOX cp -a /data/$i/* /mnt/asec/mtddata/$i/;

$BUSYBOX rm -rf /data/$i/*;

fi;

done;

if [ ! -d /mnt/asec/mtddata/misc ];

then

$BUSYBOX mkdir /mnt/asec/mtddata/misc;

fi

$BUSYBOX chown 1000.9998 /mnt/asec/mtddata/misc;

$BUSYBOX chmod 01771 /mnt/asec/mtddata/misc;

if [ -d /data/misc ] && [ ! -h /data/misc ];

then

$BUSYBOX cp -a /data/misc/* /mnt/asec/mtddata/misc/;

$BUSYBOX rm -rf /data/misc/*;

fi;

if [ ! -d /mnt/asec/mtddata/property ];

then

$BUSYBOX mkdir /mnt/asec/mtddata/property;

fi

$BUSYBOX chown 0.0 /mnt/asec/mtddata/property;

$BUSYBOX chmod 700 /mnt/asec/mtddata/property;

if [ -d /data/property ] && [ ! -h /data/property ];

then

$BUSYBOX cp -a /data/property/* /mnt/asec/mtddata/property/;

$BUSYBOX rm -rf /data/property/*;

fi;

for i in property misc system;

do

if [ -d /data/$i ] && [ ! -h /data/$i ] ;

then

$BUSYBOX rm -rf /data/$i/*;

else

$BUSYBOX rm -rf /data/$i;

$BUSYBOX mkdir /data/$i

fi;

$BUSYBOX mount --bind /mnt/asec/mtddata/$i /data/$i;

done;

if [ -e /dev/block/mmcblk0p3 ]; then

#realdata=/mnt/asec/extdata/

realdata=/data/

else

realdata=/data/

fi

cd /data

filelist=`$BUSYBOX find data -type d -follow -name "com.android.providers.*" -maxdepth 1`

for i in $filelist

do

if [ -d $realdata/$i ] && [ ! -h $realdata/$i ];

then

$BUSYBOX cp -a $realdata/$i /mnt/asec/mtddata/data/

$BUSYBOX rm -rf $realdata/$i/*

fi

done

cd /mnt/asec/mtddata/

filelist=`$BUSYBOX find data -type d -name "com.android.providers.*" -maxdepth 1`

for i in $filelist

do

if [ -d $realdata/$i ] && [ ! -h $realdata/$i ] ;

then

$BUSYBOX rm -rf $realdata/$i/*

else

$BUSYBOX rm -rf $realdata/$i

$BUSYBOX mkdir $realdata/$i

fi

$BUSYBOX mount --bind /mnt/asec/mtddata/$i /data/$i

$BUSYBOX touch /mnt/asec/mtddata/$i/ownhere-binded

done

cd /

cd /data

filelist=`$BUSYBOX cat /data/system/packages.xml|$BUSYBOX awk '{if ($0~/^<package name=/ && $3~/\/system\/app/ && !($2~/name=\"com.htc.cs\"/)) {print "data/" substr($2,7,length($2)-7)}}'`

for i in $filelist

do

if [ ! -e $realdata/$i/ownhere-binded ];

then

if [ -d $realdata/$i ] && [ ! -h $realdata/$i ] ;

then

if [ ! -e /mnt/asec/mtddata/$i/ownhere-binded ] ;

then

$BUSYBOX cp -a $realdata/$i /mnt/asec/mtddata/data/

$BUSYBOX rm -rf $realdata/$i/*

sync

else

$BUSYBOX rm -rf $realdata/$i/*

fi

else

$BUSYBOX rm -rf $realdata/$i

$BUSYBOX mkdir $realdata/$i

fi

if [ ! -e /mnt/asec/mtddata/$i ];

then

$BUSYBOX mkdir /mnt/asec/mtddata/$i

$BUSYBOX chown 1000.1000 /mnt/asec/mtddata/$i

$BUSYBOX chmod 777 /mnt/asec/mtddata/$i

fi

#$BUSYBOX ln -s /mnt/asec/mtddata/$i $realdata/$i

$BUSYBOX mount --bind /mnt/asec/mtddata/$i /data/$i

$BUSYBOX touch /mnt/asec/mtddata/$i/ownhere-binded

fi

done

cd /

setprop cm.a2sd.active 1;

echo "+++ Data-to-EXT successfully enabled";

else

setprop cm.a2sd.active 0;

echo "+++ Data-to-EXT disabled";

fi

sync;

Booce