[Galaxy Ace II General] nieltg:
HI there! Just wanna share about things I've done some time ago.. :D

Background... :fingers-crossed:

I'm interested with ROM development & testing, but.. Ace 2 is my only primary phone which I really need for school things, poking friends *woah* and.. etc. Actually, I can make a CWM backup, flash the ROM and restore the backup after testing. But... seriously! It takes quite lot of time and... yeah.. since I'm testing ROM, I'll keep flashing & reflashing my phone and I get a little worried about its internal memory if I do it too often. So, I decided to make something that let me boot new ROM which I flash on the SD card & switch back to the previous ROM with just a simple reboot.. Yeay!

How it works? ;)

I accomplished my goal by using modified initramfs which run

after

the kernel initialization and

before

any of Android system get loaded. It will mount 2nd partition of the SD card. If it find a file named enable_sdboot inside, it will decompress SD ROM's ramdisk.cpio which is stored in that partition, then boot the SD ROM. It will also delete enable_sdboot file immediately after checking, so internal ROM will get booted in next reboot.

Important notes:

SD ROM's ramdisk.cpio must contains modified fstab & some of .rc files, so it won't touch the internal ROM.

Kernel modules are placed on initramfs (/lib/modules), so it'll be easier to change ROMs or the kernel itself.

Limitations: because initramfs is compiled with the kernel, so internal & SD ROM will boot using same kernel.

Preparations :p

Prepare the Kernel

If you want to use stock ROM (codina) as ur internal ROM & CWM as ur recovery, you can use my precompiled kernel: codina-ace2nutzer-sdboot-stock-unsigned.zip which you can flash via CWM. If you use other internal ROM, you have to compile the kernel by yourself. If you're building Android ROMs, you can add my repo: nieltg/codina-initramfs-sdboot to your local manifest and read this guide. You can also take a look at this repo: nieltg/android_device_samsung_codina as an example.

If you build an out-of-tree kernel, you can follow these steps:

Create a folder named codinaramfs_dir in your kernel source.

Extract my initramfs intermediate: codina-sdboot-intermediates.zip to folder you've just created.

Replace boot.cpio with ur internal ROM ramdisk, so you can boot into it. You can also replace recovery.cpio with recovery system you would like to use.

Configure ur kernel & execute scripts/config --file .config --set-str CONFIG_INITRAMFS_SOURCE codinaramfs_dir/initramfs.list.

NOTE: .config is generated in output directory after configuring. If you change the output directory, you should modify the command before executing.

Compile and execute make INSTALL_MOD_PATH=codinaramfs_dir/modules modules_install to put modules in codinaramfs_dir/modules.

Modify codinaramfs_dir/initramfs.list to include all kernel modules in codinaramfs_dir/modules.

NOTE: I've specified the details in codinaramfs_dir/initramfs.list itself.

Then, recompile ur kernel.

Prepare an SD ROM & ur Device

You have to repartition ur SD card to store ur SD ROM. You also have to modify any ROM you want to install into ur SD card. ROM in SD card should not touch internal ROM. It should work independently. So, there are some modifications you must apply. There are things which you must ensure:

Any flashable zip you apply for the SD ROM extracts to SD partitions instead of internal.

Kernel is not going to be replaced after flashing any flashable zip.

SD ROM mounts appropriate SD partitions instead of internal partitions.

SD & internal ROM look for kernel modules in /lib/modules.

You can read this guide to prepare an SD ROM & ur device, to be exact, ur SD card.

----------

Well.. this is not good enough. You have to understand Linux, shell commands, compilation process, etc to apply this idea correctly. But of course if you're interested, you can help me improve this. Sorry for my English, I'm still studying. And like usual, I'm not responsible if you brick your phone, void your warranty, or any other pain or suffering you may feel as result of applying my idea. You do it all at your own risk!

Thanks to: [MENTION=5840412]ace2nutzer[/MENTION] for ur kernel, [MENTION=4947931]Rox[/MENTION] & [MENTION=3300472]jereksel[/MENTION] for the CWM I took from ur repo, [MENTION=6020581]ishtiaque9[/MENTION] for ur support, everyone who interested with my idea & everyone.. :D

So, anyone interested with my idea? ;)