[Galaxy S II Android Development] hawkerpaul:
The JB XXLSJ leak and the latest XWLS8 official JB releases have introduced a new partition on /dev/block/mmcblk0p12 mounted to /preload.

This was required due to the fact that the /system partition just isn't big enough to hold all the extra apps the JB leak requires.

The problem with this is that with the exception of PhilZ Kernel and Jeboo, CWM backups in bith Siyah and DorimanX omit the backing up this /preload partition. If you regularly try out different ROMs and restore back, this can mean your ROM's getting a little out of step as it would have the /preload files from the ROM you last flashed, with all other files coming from the ROM you performed the backup on.

Currently, if you are on Siyah/Dori, the only way to backup/restore everything via CWM backups is to:

a) reboot into recovery

b) flash PhilZ/Jeboo

c) go to advanced>reboot recovery

d) make your backup in PhilZ/Jeboo/Apolo recovery

and if you want to revert back to Siyah/Dori:

e) flash Siyah/Dori

f) advanced>reboot recovery

If you ever need to restore, and you are using Siyah/Dori then you will need to:

a) reboot into recovery

b) flash PhilZ/Jeboo

c) go to advanced>reboot recovery

d) restore your backup in PhilZ/Jeboo/Apolo recovery

e) flash Siyah/Dori

f) reboot

NOTE: Later versions of PhilZ require you to specifically set the backup/restore of /preload. This is done in PhilZ CWM Recovery:

1. boot into PhilZ recovery

2. Philz settings

3. Special backup and restore

4. Misc nandroid settings

5. Toggle /preload processing (make sure this says /preload will be processed)

To get around this current omission in Siyah and Dori, I have written the following 2 CWM flashable zips:

GS2PreloadBackup

This will backup your current /preload partition.

The backup is made on a per-ROM basis to /sdcard/MyBackups/preload/[ROM-Name]/preload.tar. Therefore, if you backup on several different ROMs, you will get several ROM folders in this preload backup location, one backup per ROM
​

GS2PreloadRestore

This will restore the /preload backup made by the above script for your current ROM.
​

So if you are on Siyah/Dori and want to make a full backup without flashing between PhilZ, you can now do the following:

1. Boot up into recovery

2. Make your CWM backup

3. Run GS2PreloadBackup.zip

Further down the line, if you ever wanted to restore this, then

1. Boot up into recovery

2. Restore your CWM backup

3. Flash GS2PreloadRestore.zip

The restore is sensitive to the ROM you are currently on, so it will only restore the /preload for you current ROM, provided you have run the backup script previously for the ROM of course.

Changing the backup location

By default, backups are made to the internal SD card in /sdcard/MyBackups as described above. You can change the backup location to the external SD card if required. This can be done by editing /sdcard/MyBackups/HawkerOptions/MyWipeOptions.prop. Within this file there is a line that tells the script where the backups are to be stored. Edit the following line as required:

BKP_LOCATION=int (backs up to INTERNAL SD Card, ie. /sdcard/MyBackups)

BKP_LOCATION=ext (backs up to EXTERNAL SD Card, ie. /storage/extSdCard/MyBackups)

Please note, that if you change the location between int/ext in MyWipeOptions.prop, your backups will not get automatically moved to the new location. You would have to manually move the current backup over to the new location if you do not want to potentially have two copies of the backups.

Test Mode

The script inside the zip file that does all the work is called GS2Hawker.sh. This can be called via adb shell/Script Manager etc. in order to perform a test dummy-run. The Test Mode goes through all the motions as per a standard CWM Recovery run, but it does not remove any files/folders in any way, and merely shows the commands it would have done.

eg. extract GS2Hawker.sh from the zip using 7Zip or similar

adb shell

sh GS2Hawker.sh PreloadBackup

sh GS2Hawker.sh PreloadRestore

Summary of Files Created/Used

1. /sdcard/MyBackups/HawkerLogs/GS2PreloadBackup.log.

2. /sdcard/MyBackups/HawkerLogs/GS2PreloadRestore.log.

These shows the activity log of what the script has done. This gets overwritten the next time you run the script.

3. /sdcard/MyBackups/HawkerOptions/MyWipeOptions.prop. Options file for all my scripts. Currently this contains the option for backup location, internal or external SD card. (See Changing the backup location above)

These scripts are of course only a temporary measure as I am in no doubt that both Siyah and Dori will both also include the /preload partition in their CWM Recovery scripts very shortly, but for now, I hope this might help one or two of you out.

Known Issues

Free space checking prior to performing the backup always returns free space on internal sdcard even when

backing up to external sd card.

For some reason, when I do a df (on Siyah, not sure about other kernels)

I get the following:

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/block/mmcblk0p11

12063840 231264 11832576 2% /mnt/.secondrom

/dev/block/mmcblk1p1 12063840 231264 11832576 2% /sdcard

/dev/block/mmcblk0p11

12063840 231264 11832576 2% /sdcard

/dev/block/mmcblk1p1 30648992 17592608 13056384 57% /emmc

It appears /dev/block/mmcblk1p1 is mounted to /emmc AND /sdcard?????!!!!

All file operations on /emmc gets performed on the extenral sd card as expected (ie your backups WILL go to external), BUT when the df command is issued to check for available space, it is performed on /sdcard! Therefore, if the script is trying to find the space left on /emmc, and the device returned from the df command is /sdcard, then an error is presumed, an no space check performed.

Please Note

I use these scripts myself between many flashes of different ROMS, and are provided here, as-is, out of my passion for development. Although every effort has been made to ensure everything works correctly on my handset I cannot be held responsible if things get messed up, or if you put something in your user-definable files that you shouldn't have included. As with everything else on here, you flash anything at your own risk. I always recommend performing a full CWM backup before attempting to flash anything onto your device. :)