[myTouch 3G, Magic Android Development] cellsafemode:
Ok. So lots of talk about ext for apps2sd and how it's being mounted as ext2 even if you formatted to ext4 etc.

Also talk about how journalling hurts performance and such. We'll tackle all those points here.

1. Howto fix the mounting of your ext partition in the meantime till your mod updates their software.

A. Pre-requisites

You must have already partitioned your sd card with an ext4 fs for apps2sd. You can do this in recovery or some other app.

You should also get the program file expert. It's awesome. But any filemanager that has root ability will work. You can do all this in terminal too so whatever floats your boat. I'll use file expert below.

B. Remount your system fs as read/write (not sure if it's actually needed since /system is mounted rw by most mods already... but it can't hurt). You can do this in file expert by hitting menu and selecting More, then the top option labeled "Mount", select read write. It should say success.

You can also do this in terminal but like i said above, i dont think this is absolutely needed but i always assumed it was so never tried this not doing it.

C. go back down directories using the back key till you hit /. Then goto /system/etc/init.d/

D. select S05mountsd (the S0# isn't important here so if yours is different dont worry). Once selected, hit menu and select file operations. Select permissions and change permissions to read/write all.

E. Open the file with a text editor of choice. Scroll down the file to the part that has the command with -t auto in it. It should be pretty obvious, and it's near the end.

Change -t auto to -t ext4. It doesn't matter if your fs is actually ext2 or ext3, mounting as ext4 is always better. The ext4 block allocator and general code is more efficient even if you dont use ext4 features.

You may also want to add an option to the options list data=writeback. This disables journal caching of actual data and only caches metadata. This is really integral to performance on such a slow medium like sd cards and we'll discuss that later.

Save your file and exit.

F. Reboot your phone. You should now have your sd-ext mounted as ext4.

2. data=writeback and why?

there are multiple modes of journalling available to ext4. The default is ordered. This means that there is a specific order that information is written to the fs to ensure that nothing is lost that is said to be written. This means metadata about the fs and file data is both cached in the journal. Safe but slow.

data=writeback still allows crash protection but means you may lose actual newly written data. Your fs wont be corrupt, but your file may not have gotten those last updates you were writing and had not synced yet. It's a pretty decent compromise.

There are other forms that offer better performance but basically remove journal integrity and we're not concerned with those.

There are also options that determine the interval of journal syncing and you can find that information on ext4 man pages.

Why do we care so much about performance here? because sd flash is slow and finite. A journal file is like swap in that it is a static file that's contents get written to anytime you write to your fs. On a normal hdd, it's not noticeable really but on a class 6 SD card, you are going to notice having to write everything twice to your sd card. So we choose writeback mode to remove that double writing and only cache fs metadata updates so that the integrity of the filesystem isn't hurt, and only that particular file that we crashed prior to syncing gets effected. 99% of the time this is fine and perfectly safe and way better than nothing.

3. So if journalling can hurt performance by using up write bandwidth to a medium we are writing other stuff on, wouldn't swap be bad too?

Yes. Swap should only be put on sd cards if you absolutely need it or your phone wont work. Aside from stressing the card, the bandwidth to read/write is extremely small for something you basically have to be interactive with and move to and from ram. Additionally android complicates matters by managing memory at a higher level than the kernel and this means that swap is ignored as a portion of memory. So while technically userspace apps deal with swap transparently, the low memory manager of android will operate as if you didn't have swap...which defeats the purpose.

Use swap as a last choice.

Also, the ability to make swap partitions and swap files is a common issue in linux-land. It's best to use a partition as this removes fs overhead but it becomes even more of a concern when you put it on an ext4 fs with journalling active. With default settings, a swap file will be considered just another file and the journal will cache the data and metadata updates (very bad for performance). if you use swap on an ext4 fs that's actually mounted as ext4 you _NEED_ to make the data option writeback. You will be very disappointed if you dont.

4. Other important notes:

If you use any ext4 specific options like extents, you will no longer be able to read the files written by recovery programs that have not been updated to mount fs's as ext4. Also, just enabling extents doesn't convert data on the fs to use them. You have to write the files while the option is enabled to see their benefit. This is more easily done by putting the card in an actual linux computer and mounting with the correct options and copying the data from the filesystem and then back again ....not for the novice. Though any new files written will automatically have extents even if you dont redo all current data. So best to bother with that after a fresh install prior to restoring apps.

You may also be thinking... Why do i even need a fat fs, i can make the whole thing ext4 and it will be awesome! You would be right, it would be awesome. But it's not so easy. A couple things have to be done in order to make everything written world rewritable and accessible on such a partition. you would have to setgid to a group like "sdcard" to a directory in this new fs and give it rwx group permissions and then have all users current and future become part of that group and mount bind the directory to /sdcard. Needless to say, recovery apps would have to also be updated. Then you could make your main sd partition any fs your kernel supports.