[G1 Android Development] Firerat:
Mine doesn't move dalvik-cache ( well its an option )

you have the option of keeping some apps on internal memory

( and you can easily 'toggle' them from sd-ext to internal )

Oh, and Mine will move FroYoFat apps for you

+ mine is much much bigger

and it mounts sd-ext

#!/system/bin/sh
# 2010-07-13 Firerat - symlink apps from /data/app/ to sd-ext/app/
# optionally leave apps on /data/app/
# optionally move froyo fat apps to sd-ext
# 2010-08-06 ==> 2010-08-12 , disbaled lots, and added better Apps2sdext + ApkManager.sh script

# start FroYo apps2sdext Functions
recoverycheck ()
{
if [ "`ls /sbin|grep -q recovery;echo $?`" = "0" ];
then
mount -a > /dev/null
recoverymode=y
else
recoverymode=n
fi
return
}

fsdextmnt ()
{
# install sd-ext mount script ( frm cm5 )
cat > /dev/05mountsd << "EOF"
#!/system/bin/sh
#
# mount ext[234] partition from sd card

BB="logwrapper busybox";
# Firerat - make mount point
if [ ! -d /sd-ext ];
then
$BB mount -o rw,remount /
install -m 774 -o 1000 -g 1000 -d /sd-ext
$BB mount -o ro,remount /
fi

if [ "$SD_EXT_DIRECTORY" = "" ];
then
SD_EXT_DIRECTORY=/sd-ext;
fi;

# IConrad01's fix for CM6
# http://forum.cyanogenmod.com/topic/2636-froyo-a2sdext/page__view__findpost__p__26124
#
MMC=/dev/block/mmcblk0
if [ ! -b "$MMC" ];
then
mknod ${MMC} b 179 0
chmod 600 ${MMC}
for i in 1 2 3;do
mknod ${MMC}p${i} b 179 $i
chmod 600 ${MMC}p${i}
done
fi

# find first linux partition on SD card
# wait for the device to settle
COUNT=6;
until [ -b "$MMC" ] || [ $COUNT -lt 1 ];
do
sleep 1;
COUNT=$((COUNT-1));
done;

if [ -b "$MMC" ];
then
FDISK="busybox fdisk"
PARTITION=`$FDISK -l $MMC | awk '/^\// && $5 == 83 {print $1;exit;}'`

if [ -b "$PARTITION" ];
then
log -p i -t mountsd "Checking filesystems..";

# fsck the sdcard filesystem first
logwrapper e2fsck -y $PARTITION;

# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
if [ "$?" = 0 ];
then

# mount and set perms
$BB mount -o noatime,nodiratime -t auto $PARTITION $SD_EXT_DIRECTORY;
if [ "$?" = 0 ];
then
$BB chown 1000:1000 $SD_EXT_DIRECTORY;
$BB chmod 771 $SD_EXT_DIRECTORY;
log -p i -t mountsd "$SD_EXT_DIRECTORY successfully mounted";
else
log -p e -t mountsd "Unable to mount filesystem for $SD_EXT_DIRECTORY!";
fi
else
log -p e -t mountsd "Unable to repair filesystem, disabling apps2sd";
fi
fi
fi
if ! awk -vDIR="$SD_EXT_DIRECTORY" '$2 == DIR { exit 1; }' /proc/mounts ;
then
# create directories if necessary.
for i in app app-private dalvik-cache;
do
if [ ! -d $SD_EXT_DIRECTORY/$i ];
then
mkdir $SD_EXT_DIRECTORY/$i;
busybox chown 1000:1000 $SD_EXT_DIRECTORY/$i;
busybox chmod 771 $SD_EXT_DIRECTORY/$i;
log -p i -t a2sd "$SD_EXT_DIRECTORY/$i created"
fi;
done
setprop cm.a2sd.active 1
log -p i -t a2sd "Apps2SD successfully activated";
fi;
EOF
if [ "`grep -q sd-ext /proc/mounts;echo $?`" != "0" ];
then
sh /dev/05mountsd
fi
# make sure with have sd-ext dirs
for dir in app app-private;do
if [ ! -d /sd-ext/${dir} ];
then
install -m 771 -o 1000 -g 1000 -d /sd-ext/${dir}
fi
done
# meh, going to force install of this script
#if [ -e /system/etc/init.d/05mountsd ];
#then
#	return
#else
instsdextmnt
#fi
return
}

instsdextmnt ()
{
mount -o rw,remount /system
install -m 700 -D /dev/05mountsd /system/etc/init.d/05mountsd
echo "mount sd-ext installed"
return
}

checkcfg ()
{
# oops, ended putting a 1 to be the default ignore in v0.6
if [ -e $internallist ];
then
sed s/^1/qwertpoiu/ -i $internallist
fi
return
}

movefroyocfg ()
{
echo "move FroYo FAT installed apps to /sd-ext? (y/n)"
echo "it can be a little slow, so if your in a rush"
echo "then answer n, you can always run the script again later"
read a
if [ "$a" = "n" ];
then
echo "FroYo FAT 2 sd-ext will be skipped"
froyo2sdext=n
elif [ "$a" = "y" ];
then
echo "FroYo fat apps will be moved to sd-ext"
froyo2sdext=y
else
echo "please enter y or n"
movefroyocfg
fi
return
}

dupecleaner ()
{
for i in `find /sd-ext/app/ /sd-ext/app-private /data/app-private /data/app -name "*apk" -type f`;do
apk=`basename $i`
echo "checking ${i}..."
if [ "`grep -q $apk /data/system/packages.xml;echo $?`" = "1" ];
then
echo "$apk is not listed in packages.xml"
echo "removing .."
rm $i
else
echo "OK.."
fi
done
return
}

all2sdext ()
{
for dir in app app-private;do
if [ ! -d /data/${dir}_i ];
then
install -m 771 -o 1000 -g 1000 -d /data/${dir}_i
fi
done
for dir in app app-private;do
for apk in `find /data/${dir}/ -type f`;do
apk=`basename ${apk}`
if [ -e $internallist ];
then
if [ "`grep -q ${apk} $internallist;echo $?`" = "0" ];
then
echo "keeping ${apk} on internal memory"
mv /data/${dir}/${apk} /data/${dir}_i/${apk}
ln -sf /data/${dir}_i/${apk} /sd-ext/${dir}/${apk}
fi
else
if [ ! -L /data/${dir} ];
then
echo "moving ${apk} to sd-ext/${dir}"
cp -a /data/${dir}/${apk} /sd-ext/${dir}/${apk}
fi
fi
done
rm -r /data/${dir}
ln -s /sd-ext/${dir} /data/${dir}
done
if [ -d "`dirname $internallist`" ];
then
rm -r `dirname $internallist`
fi
return
}

fat2ext ()
{
for apk in `find /mnt/asec/ -type d|grep -v asec/\$`;do
echo "moving `basename ${apk}.apk` to internal ( temp )"
if [ -e /mnt/secure/asec/smdl2tmp1.asec ];
then
rm /mnt/secure/asec/smdl2tmp1.asec
fi
pm install -f -r ${apk}/pkg.apk
done
return
}

ApkManager ()
{
cat > /dev/ApkManager.sh << "EOAPKMANAGER"
#!/system/bin/sh
if [ ! -e /system/bin/ApkManager.sh -o "$1" = "force" ];
then
busybox mount -o rw,remount /system
cat > /dev/ApkManager.sh << "EOF"
#!/system/bin/sh
# ApkManager.sh v0.3
me=$0
applist=/dev/appslist.txt
find /data/app_i /data/app-private_i /sd-ext/app /sd-ext/app-private -type f -name "*apk" -exec ls -lh {} \; \
|awk 'sub(/\/sd-ext/,"sdext /sd-ext") sub(/\/data/,"Internal /data") ( ++c ) {print "["c"] "$9"\t"$5"\t"$10};' > $applist
awk 'sub(/\/.+ap.+\//,"") sub(/-.\.apk/,"")' $applist
apkcount=`sed -n '$=' $applist`
echo -e "enter app number to Toggle location\n( use a space when toggling more than one app )"
echo "eg: 10 12 45"
echo "or q to keep existing list"
read toggle
toInternal=""
toSdext=""
for app in $toggle;do
toSdext="${toSdext} `awk '/\['${app}'\]\ Internal/ {print $4}' $applist`"
toInternal="${toInternal} `awk '/\['${app}'\]\ sdext/ {print $4}' $applist`"
intcount=`echo $toInternal|sed s/\ /"\n"/g|grep sd-ext|sed -n '$='`
#symlinksize=`expr $intcount \* 47`
done

for i in toInternal toSdext;do
eval files=\$${i}
if [ "`echo $files|grep -q apk;echo $?`" != "0" ];
then
eval ${i}Size=0
else
eval ${i}Size=`du -c $files|awk '/total/ {print $1}'`
fi
done

dataAvailable=`df |awk '/\/data/ {print $4}'`
sdextAvailable=`df |awk '/\/sd-ext/ {print $4}'`

datapostmove=`expr $dataAvailable - \( $toInternalSize - $toSdextSize \)`
sdextpostmove=`expr $sdextAvailable - \( $toSdextSize - $toInternalSize \)`

if [ "$datapostmove" -lt "10240" ];
then
echo "It looks like free space on data is going to fall below 10mb"
echo "are you sure you want to continue? (y/n)"
read a
if [ "$a" = "y" ];
then
echo "OK, you can always come back and move it again ;)"
else
echo "will skip moving apps to internal"
movetointernal=n
fi
fi

if [ "$sdextpostmove" -lt "0" ];
then
echo "not going to have enough space on sd-ext"
echo "skipping"
movetosdext=n
fi

for app in $toggle;do
location=`awk '/\['${app}'\]/ {print $2}' $applist`
apk=`awk '/\['${app}'\]/ {print $4}' $applist`
if [ "$location" = "Internal" ];
then
if [ "$movetosdext" != "n" ];
then
echo "moving ${apk}..."
find `dirname $apk|sed -e s/data/sd-ext/ -e s/_i//` -type l -name "`basename $apk`" -exec rm {} \;
cp $apk `dirname $apk|sed -e s/data/sd-ext/ -e s/_i//`/
rm $apk
fi
elif [ "$location" = "sdext" ];
then
if [ "$movetointernal" != "n" ];
then
echo "moving ${apk}..."
cp $apk `dirname $apk|sed s/sd-ext/data/`_i/
ln -sf `echo $apk|sed -e 's/sd-ext/data/' -e 's~/~_i/~3'` `dirname $apk`/
fi
else
return
fi
done
rm $applist
echo "================================="
echo "`basename $me` to manage apps "
echo "---------------------------------"
EOF
install -g 0 -o 0 -m 755 /dev/ApkManager.sh /system/bin/ApkManager.sh
ln -sf /system/bin/ApkManager.sh /system/bin/apkmanager.sh
busybox mount -o rw,remount /system
echo "ApkManager installed"
fi
EOAPKMANAGER

install -m 700 -g 0 -o 0 -D /dev/ApkManager.sh /sd-ext/userinit.d/55ApkManager
rm /dev/ApkManager.sh
sh /sd-ext/userinit.d/55ApkManager force
sh /system/bin/ApkManager.sh
return
}

# end FroYo apps2sdext Functions
# setup env
internallist=/data/a2sd-ext/internal.cfg
version="1.2"
# run
echo "a2sd for FroYo version $version"
echo ""

if [ "`echo $@ |grep -q dupefix;echo $?`" = "0" ];
then
dupecleaner
exit
fi

fsdextmnt
recoverycheck
if [ "$recoverymode" = "n" ];
then
movefroyocfg
else
echo "FroYoFat2sdext is not available in recovery"
fi
checkcfg
all2sdext
if [ "$froyo2sdext" = "y" ];
then
fat2ext
fi
ApkManager
echo "FroYo apps2sdext complete.."
exit