[Galaxy S Advance I9070 Android Development] xanonus:
Expert root method which does not increase the flash counter

For reference, I want to post here a root method which does not increase the flash counter, but which is a little bit complicate, and therefore only for devs and other advanced users. For real developers this method should be not new or special, but as it was not mentioned for the Galaxy Advance i9070(P) before one might be interested.

It needs a Linux system with root access. Of course, a VM would do it.

I explain the needed steps not in all details to stop normal users which should first learn basic Linux shell commands... For them qzem's kernel root method is in my eyes the best and easiest way to root their phone.

The idea of this root method is not to flash a modified kernel/initrd which then modifies the system on startup but to flash directly a modified system.img.

The benefit is that Samsung's flash counter is not increased.

The drawback is that the system.img is quite huge and therefore I will not provide any pre-rooted system.img. You need to do it by yourself:

Get the system.img.md5 for your i9070(P) (extract the official ROM .zip package two times). Use samfirmware.com if possible or read my post how to get all roms directly from Samsung.

Convert system.img.md5 to ext4 (see this thread how to do it)

do the following steps as root user (use "su" or "sudo bash" on ubuntu based systems)

loop-mount the image:

mkdir system
mount system.img.ext4 system -o loop,ro

copy everything to a new place where you can write to:

cp -ar system new_system

Add the su program of SuperUser or SuperSu to new_system/xbin/.

You can extract it for example from the .zip files linked in those threads. Then set correct permission:

chown root:root new_system/xbin/su
chmod 06755 new_system/xbin/su

(I do not know if this step is really necessary) Copy files from your phone's /system folder (CSCFiles.txt, CSCVersion.txt, SW_Configuration.xml T9DB/ subfolder and maybe more) to new_system/. One way to to this, is "adb pull". It works also for whole directories, but note that it does not preserve any file rights. With "adb shell" you can examine your smartphone first to see what files are in the /system/ folder and what file rights they have ("ls -l" is your friend).

Pack everything back to a new flashable compressed ext4 image:

/path/to/your/ext4_utils/mkuserimg.sh -s new_system ./new_system.img ./tmp 612M

Put your phone into download mode (the cheap USB JIG is the best way and helps to recover your phone in the case you made a big mistake. The jig for SGS2 and other Samsung smartphones works for the i9070(P), too.)

Then either flash the new_system.img with Heimdall on

/path/to/heimdall flash --system new_system.img

Or use Odin on Windows [not tested by me]. Here you need to rename new_system.img to system.img.md5 (copy it first to new place if you want to keep the stock system.img.md5...) Then

md5sum system.img.md5 >> system.img.md5
tar cf for_ordin.tar.md5 system.img.md5
md5sum for_ordin.tar >> for_odin.tar.md5

And flash for_odin.tar.md5 with Odin as PDA (?), maybe you need to select the .pit file first you can find here... Do not repartition your device or update the boot loader...

Start your phone and install the SuperUser or SuperSU app depending on the su binary you have chosen.

Enjoy your rooted system, click the thanks button and think about how you can give something back to the community ;)