[Android Software/Hacking General [Developers Only]] timbit123:
thanks for your script, I adapt it to be in the build of the Medroid cm9 for nexus one

mounting and moving partition are in an other script that also check of there is no error in the ext.

after that, when they launch for the first time, it check if there is an old app2sd in the ext partition and copy it to /sd-ext(internal)

after that this is lunching.

any suggestion would be great :)

#!/system/bin/sh
#
# Script created by amarullz
# Modified by Timothé Fillion Brunet for the new app2sd
#
# Last update date : 25-01-2012
#
# *Script running for Medroid CM9 version*
##
# IF GUIDE HELP
# -e = file exist
# -a = AND
# -o = OR
# -d = directory
# -h = symlink directory

if [ "$SD_EXT_DIRECTORY" = "" ];
then
SD_EXT_DIRECTORY=/data;
fi;

BB="/system/xbin/busybox";

# check if 07checkOldVersion exist
if [ -e /system/etc/init.d/07checkOldVersion ]
then
$BB mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system;
$BB rm -f /system/etc/init.d/07checkOldVersion;
fi;

# check if sd ext partition is mounted otherwise EXIT like a boss
if [ ! $BB mount | grep /data ]
then
if [ ! $BB mount | grep /sd-ext ]
then
exit;
fi;
fi;

if [ ! -f $SD_EXT_DIRECTORY/.ITim2sd ]
then
rm -rf $SD_EXT_DIRECTORY/*;
echo "." > $SD_EXT_DIRECTORY/.ITim2sd;
#clear dalvik from /sd-ext just to be secure and not have half of dalvik
$BB rm -f /sd-ext/dalvik-cache;
firstBoot=true;
fi;

###[ SDEXT SD_EXT_DIRECTORY STRICT ]###
# app, app-private, data : should in /data (SD_EXT_DIRECTORY)
###
for i in app app-private data;
do
#-- If Symlink in /data, delete it
if [ -h /data/$i ]
then
$BB rm /data/$i;
fi;

#-- If Directory Not Extst in /data, create it
if [ ! -d /data/$i ]
then
$BB mkdir /data/$i;
$BB chown 1000:1000 /data/$i;
$BB chmod 0771 /data/$i;
fi;

#-- If Directory Exists in /sd-ext, move it to /data
if [ -d /sd-ext/$i ]
then
$BB mv -f /sd-ext/$i/* /data/$i;
#remove old folder from /sd-ext (internal, no more needed after moved)
#will also give more space
$BB rm -rf /sd-ext/$i;
fi;
done;
cd /;

###
# It should also need to create the rest non Symlink Directories and Files on /data to /sd-ext
# if some folder are created in the (/data(ext)) and are not coming from
# app, app-private, data. move it back to the internal... we never know :)
###
cd /data;
for i in `ls -a`;
do
if [ $i != ".." -a $i != "." -a $i != "app" -a $i != "app-private" -a $i != "data" ]
then
if [ -d /data/$i ]
then
if [ ! -d /sd-ext/$i ]
then
$BB mv -f /data/$i /sd-ext/$i;
fi;
fi;
fi;
done;
cd /;

###
# Now create symlink of the rest non Symlink Directories and Files on /sd-ext to /data
###
cd /sd-ext;
for i in `ls -a`;
do
if [ $i != ".." -a $i != "." -a $i != "data_s" -a $i != "app" -a $i != "app-private" ]
then
if [ ! -h /sd-ext/$i ]
then
if [ ! -h /data/$i ]
then
$BB ln -s /sd-ext/$i /data/$i;
fi;
fi;
fi;
done;
cd /;

###
# System application will read/write in Internal memory, and 3rd apps will run on sdcard
###

#-- Prepare data_s in /sd-ext ( For system data )
if [ ! -d /sd-ext/data_s ]
then
$BB mkdir /sd-ext/data_s;
$bb chown 1000:1000 /sd-ext/data_s;
$bb chmod 771 /sd-ext/data_s;
fi;

#-- Now Move those files into Internal Memory
applist="com.android.* com.google.android.* com.cyanogenmod.* com.keramidas.TitaniumBackup";
exceptlist=""
cd /data/data/;
for i in `ls -d $applist`;
do
#-- Only Non Symlink
if [ ! -h /data/data/$i ]
then
$BB mv -f /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
$BB ln -s /sd-ext/data_s/$i /data/data/$i
fi;
done;

#if it was the first boot, reboot :)
if [ $firstBoot ]
then
$BB reboot -f;
fi;

#-- Of Finished.... :D