[G1 Android Development] Firerat:
EDIT: 2010-05-13

a note on this modded a2sd and CM5

This mod is *not* required , cm5 has a newer/better way of implementing a2sd

but it will do no harm, it just simply won't do anything

Firerat Patch - a2sd for MT3G users

NOTE My Modified a2sd is intended for both G1s and MT3Gs, one a2sd suits both MT3G's and G1s

Ok, I thought it was about time I gave a full explanation on my mt3g-a2sd patch

why MT3G users should not use an ext partition

why MT3G users who have just 2 Parttions ( FAT / SWAP ) get failed boots

How my modifications reslove this situation

Why should MT3G users not use an ext partition?

the answer is quite simple really, they don't need it.

a2sd was designed with G1s in mind, the G1's /data partition has a limited amount of space available, just over 74mb or 89mb with 'DangerSPL' whereas the MT3G has just over 295mb around 3 or 4 times the G1's.

Although I have not 'benchmarked' the 'speeds' of internal vs sdcard , I belive it is widely accepted that the internal memory is significantly faster than sdcards, and therefore if an MT3G can use it, it should.

So I hope we are all now agree that the MT3G's internal memory should be used for apps/dalvik-cache

Why do MT3G users who have just 2 Parttions ( FAT / SWAP ) get failed boots?

the problem is within the a2sd script, here is a section of the code, with my annotations in blue

[COLOR="Blue"]Here the script checks for second partition[/COLOR]
if [ -e /dev/block/mmcblk0p2 ];
then

[COLOR="Blue"]it exists so it does a fsck on it [/COLOR]

# fsck the sdcard filesystem first
e2fsck -fy /dev/block/mmcblk0p2;

# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
[COLOR="Blue"] an error is returned ( it is swap not an extfs ) error no. is just stored, no action [/COLOR]

# mount and set permsd
busybox mount -o noatime,nodiratime -t auto /dev/block/mmcblk0p2 /system/sd;

[COLOR="Blue"] The above mount command fails, it is swap
<snip some link clean ups>[/COLOR]

# move apps and dalvik cache from internal memory to sdcard
for i in app app_s app-private dalvik-cache;
do
[COLOR="Blue"] here directories are normally created on sdcard
but as sdcard isn't mounted it tries to put them on the /system partition,
since /system is mounted read only , it fails[/COLOR]
if [ ! -d /system/sd/$i ];
then
mkdir /system/sd/$i;
fi

busybox chown 1000:1000 /system/sd/$i;
busybox chmod 771 /system/sd/$i

if [ -d /data/$i ] && [ ! -h /data/$i ];
then
[COLOR="Blue"] the next line tries to copy files from internal memory to /system/sd,
which is read only, it fails[/COLOR]

busybox cp -a /data/$i/* /system/sd/$i/;

busybox rm -f /data/$i/*;
[COLOR="Blue"] BANG , that line above just deleted all your apps,
your system will not boot[/COLOR]
fi;
done;

# symlink app dirs - they must be on the same filesystem
for i in app app_s app-private;
do
if [ -d /data/$i ] && [ ! -h /data/$i ];
then
busybox rm -rf /data/$i;

[COLOR="Blue"] its just removing empty directories,
and creating a link to none existent directories in /system/sd/[/COLOR]

busybox ln -s /system/sd/$i /data/$i;
fi;
done;

How my modifications reslove this situation

Quite simply by skipping the above code, with this.

# check if not a G1 ( assuming mt3g ) - Firerat 2010-03-23
rohardware=`getprop ro.hardware`
if [ "$rohardware" != "trout" ];

then
FindSwap
ReturnAppsToData
$SETPROP_CMD cm.filesystem.ready 1;
exit 0;

the != is not equal to, getprop ro.hardware will return sapphire, not trout,

so this code will run my findswap, and ReturnAppsToData Functions

you can find the ReturnAppsToData Function in my next post

FindSwap ()
{
if [ "`sed -n '$=' /proc/swaps`" -gt "1" ];
then
echo "Swap appears to be already setup, skipping checks"
return
else
for isitswap in `ls /dev/block/mmcblk0p*` ; do
swapon $isitswap 2>/dev/null
if [ "$?" = "0" ];
then
busybox mount -o rw,remount /system
sed s~/dev/block/mmcblk0p.~$isitswap~ /system/bin/user.conf -i
busybox mount -o ro,remount /system
break
else
echo "$isitswap is not swap"
fi
done
fi
return
}

next post contains my full modified a2sd

New Version 2.1

FireratModified-a2sd-2-1_S.zip

This one has the functions in the right place, so they *will* do something

################

Older versions

################

are a bit broken