[Galaxy S II Q&A, Help & Troubleshooting] aferreiro:
If you are reading this, DON'T TRY IT UNLESS IT'S VERIFIED BY SOMEONE IN THIS THREAD.

First of all, this is my first post here in xda, so I'll try it to be as helpfull as possible to other users doing a guide of how to backup your international i9100 to an Odin flashable rom, so you can restore all of your configurations at once, including installed programs, accounts... everything in your phone.

But why? I want to backup my S2 to an Odin rom before I try ICS 4.0.3, because it could take my several ours to restore everything to the way it was before updating in case I don't like it. Yes, I know what Titanium backup is, I have my phone rooted and I do a programmed backup each day at 3am. But I still want to be able to do it in just ONE step with Odin without dealing with Titanium backup's filters and system's apps.

So it's a great way to restore your phone to it's previous state for all of you that install a new rom and doesn't like how it works, or may be you are having issues after upgrading, or just want to take a look and go back quickly. Just one step and three minutes with Odin.

But in the case of ICS 4.0.3 you have to repartition your phone both ways, when upgrading and when downgrading, and that's first rule of the Odin's club: Don't touch the repartition option (of course, it's also second rule :D).

Anyway, I'm posting a guide to do it in i9100 that HAS TO BE VERIFIED by someone with enough knowledge about how the partitioning works. It must work fine if you stay between 2.x versions without repartitioning, but as I told before, I don't know for sure, as I'm a bit confused about which partition is each one and which ones are needed to be backed up.

So please, if someone has enough knowledge to do it safely, post a reply with corrections to this method.

Here is the guide

HOW TO BACKUP A PARTITION

To backup a partition, you must open a terminal emulator, or conect from your computer via adb shell, and use dd command (duplicate disk) in su mode to create a backup of your partitions. Don't ask me how, if you don't know, you shouldn't be reading this. You will compress them later to load them in Odin.

ABOUT PARTITIONS

Each device has different names for the same partitions. For example, /system partition might be /dev/block/mmcblk0p9 in i9100, but in Samsung Continuum it's /dev/block/stl9.

So, in Galaxy SII partitions are (taken from here by HellcatDroid)

To see them in your device, open an adb shell, and type cat /proc/mounts. If you do it in i9100, you will find something like this:

~ # cat /proc/mounts
cat /proc/mounts
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=111 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/usb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /app-cache tmpfs rw,relatime,size=7168k 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
[B]/dev/block/mmcblk0p9 /system ext4 ro,relatime,barrier=1,data=writeback,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p7 /cache ext4 rw,nosuid,nodev,noatime,barrier=1,data=writeback,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p1 /efs ext4 rw,nosuid,nodev,noatime,barrier=1,data=writeback,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p10 /data ext4 rw,nosuid,nodev,noatime,barrier=1,data=writeback,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p4 /mnt/.lfs j4fs rw,relatime 0 0[/B]

So... How do I backup partitions

According to HellcatAndroid, and for Galaxy S2 i9100, you have to backup using this commands:

dd if=/dev/block/mmcblk0p1 of=/sdcard/p1-EFS.img bs=4096
dd if=/dev/block/mmcblk0p4 of=/sdcard/p4-PARAM.img bs=4096
dd if=/dev/block/mmcblk0p5 of=/sdcard/p5-KERNEL bs=4096
dd if=/dev/block/mmcblk0p8 of=/sdcard/p8-MODEM.bin bs=4096
dd if=/dev/block/mmcblk0p9 of=/sdcard/p9-FACTORYFS.rfs bs=4096
dd if=/dev/block/mmcblk0p12 of=/sdcard/p12-HIDDEN.img bs=4096

but as you see, not all of them are visible, but all of them will backup.

Some authors also claim you need to mount filesystem as RW (mount -o rw,remount /dev/block/mmcblk0p9 /system). It worked for me without mounting it as RW.

Someone please confirm this step is enough to backup everything, and there is no need to remount as RW.

If you want to backup your data, run Someone please confirm this step is correct

dd if=/dev/block/mmcblk0p10 of=/sdcard/p10-DATA bs=4096

Creating Odin image

Next step is to create the tarball of the dumped partitions. Copy or move the generated .img files to another folder, and create the tarball typing the following command into a linux terminal (you can do it in a VM or in cywin):

tar -H ustar -c p9-FACTORYFS.rfs p8-MODEM.bin p5-KERNEL > i9100backup.tar

If you want to add your data, you must run instead Someone please confirm this step is correct

tar -H ustar -c p9-FACTORYFS.rfs p8-MODEM.bin p5-KERNEL p10-DATA > i9100backup.tar

After that, add the md5 checksum:

md5sum –t i9100backup.tar >> i9100backup.tar
mv i9100backup.tar i9100backup.tar.md5

And that's all, i9100backup.tar.md5 is your Odin rom.

CONSIDERATIONS IF YOU ARE MOVING TO ICS FROM GINGERBREAD AND BACK

Someone please confirm this step is correct

When you upgrade to ICS, you have to tick repartition option, and do it again when downgrading. So you will need a .PIT file with information about your partition table to be able to do it right without bricking your phone.

So if you want to enable your rom to be used for a downgrade from ICS, you must run

dd if=/dev/block/bml2 of=/sdcard/FILENAME.pit bs=4096

and add it to the rom when creating the tarball. READ BELOW

In this case, bml2 is for Galaxy S, NOT FOR GALAXY S2 I9100, so please someone help finding i9100 filesystem.

WARNING

Doing this step wrong, can brick your phone permanently.

Sources:

How to build ODIN flashable ROMs for Samsung Galaxy S Series

[Q] How to Backup and Restore Original Shipped Firmware? For warranty.

Creating Custom ROMs/Backups for Odin