[AT&T Samsung Galaxy S II Skyrocket SGH-I727] car vs driver:
This post is VERY IMPORTANT.

Have you been using the stock formatted updater-script to install your ROMs? Well, you're doing it wrong ... and I'm going to tell you why.

Well, sort of. I can't exactly explain why the problem exists, only that it does and how to solve for it.

The problem I'm talking about is when you want to format a partition as well as properly, and safely mounting partitions to install your packages to. Have you ever noticed that when you format a partition that it takes milliseconds in the updater-script but when in recovery it takes longer? That's because the default script is doing it wrong.

What I typically see is that people will issue the format() on a mounted volume. Quite simply, this fails to work and causes a number of oddball problems. It'll either not do anything (resulting in a dirty flash) or it'll lock the volume and you cannot remount it later to push your packages to, you'll get any number of errors that state something to the effect of "the target volume is busy, mount failed"

I have no idea why this happens, if you do please chime in. But I do know how to fix it and provide your users a better install experience, with or without Aroma.

Here's what you need to do. I should also mention, this will lead to less headaches for you in the long run in supporting your ROM. There will be less issues related to installation and dirty flashes. In my ROM, I use Aroma which lets the user choose how to wipe their data, if you aren't using aroma, there's still some good housekeeping here ...

1. Make sure do include the busybox binary in your flashable zip. For this example, I'll assume you put it in a directory called /tools. Never assume that the target device has this installed already, bring all your own tools with you. Always.

2. The very first thing to do in your script is to extract busybox and make it executable in /tmp. This lets us use it for mount/umount.

3. Below is how to mount your main partitions on the skyrocket.

4. Ok, so that's all well and good. Now that we have them mounted, you can run your deletes to clear data.

5. Ok great, so what about formatting? Glad you asked. They key to formatting properly is to umount your target before running the format. If you don't, weird stuff happens. Errors, non formatted data, locked volumes, etc. This is also the reason why people say to wipe things repeatedly before flashing a ROM. Now you don't have to!! What you'll notice here is that each format command will take far longer than it did previously (if the volume has data), that's because it's actually working properly now.

When you get a clean format, your log file will look something like this:

6. Now what? Well, now you can remount the necessary volumes with busybox and run your installation.

That about covers the basics. I've spent the past week or two, eye ball deep, in these scripts and have learned a crap load about how it works and the best way (IMHO) to approach it. Hope this helps you guys out. Never assume that your updater-script is going to do what you think it will if you don't actually read logs and verify it along the way.

Remember, deleting anything in /data (outside of /data/dalvik-cache) is a risky proposal toward your potential users. If you do this, make sure you state up front that it will happen, or use Aroma and give them the choice of wiping everything from /data.

Here are some other tips to make things a bit cleaner.

Use the assert() function when you need it. For example, confirm your mount worked:

I add a timer at the end of my script to wait for any background writes to finish. Best I can figure is that sometimes, writes will fire off and the script moves along without waiting. So, you can catch that by adding the following command near the end (assuming you are using Aroma) before you umount and end the install:

Oh, I almost forgot ... right after you extract and prepare busybox, it's a good idea to issue a set of mass unmounts to be sure you get a clean mount for your installation.

Lastly, lastly, really ...

You can really screw things up with the format command. Double, triple, quadruple check your parameters to make sure you're formatting the right volume. If not, you could potentially hard brick a device. Consider yourself warned, and consider me free of liability :)

Please post any questions to the thread about this. No matter how trivial you think it may be, it'll only benefit the other 5 people unwilling to ask.