I have followed these guidelines to create Dual-Boot on four different phones and I suppose that the same method can be used for any phone.
The idea is to keep any stable ROM as primary and install an AOSP-based JB (4.1) or newer ROM on the SD-card.
WARNING: If you are not familiar with the way Android works, you can easily brick your device by flashing the wrong partition. I won't assume responsibility if you do and I can't offer support since I cannot possibly own all the devices this guide may be applicable to. If you don't fully understand these guidelines, then stay away. If you still want to try, remember, you are on your own! Questions, suggestions and remarks should be properly posted in the thread for everyone to read. Take no ofense, I will not reply to PMs.
A) You need to fully unlock your device (Root, Bootloader unlock, S-Off or whatever else your device has that may prevent you from flashing partitions).
B) You need to find a suitable way to unpack and repack your boot.img. Different ways are available for different devices. I can only suggest those that I have tested for mine.
C) You need to have a working updated busybox.
D) A ROM zip file to install onto the SD card. This ROM must NOT be using Aroma Installer.
1. First you need to figure out the locations and sizes of your system, data, cache and boot partitions (you can use Partition Table from Play Store).
2. Create three additional partitions at the end of your SD card with the sizes you found. You can either use AParted on your phone or MiniTool and a card adapter on your PC. The partitions must be all primary and formatted to ext4.
(HINT1: If you use AParted, you probably want go hit "Decline" on the agreement, otherwise it will install adware junk)
(HINT2: You may want to create a larger Data partition, so that you have more space to install apps)
(HINT3: If you can convert ZIPs using DBootRecovery from 2nd post, then do it and jump to step 7)
3. Now you have to unzip the ROM file you want to install, browse to /META-INF/com/google/android, find the updater-script and edit all lines that contain mmcblk0ps (where s is your internal system partition number) to mmcblk1p2 (your new SD-system partition). Some ROM zips (like MIUI) also install stuff to the data partition, so be careful and change the respective lines from mmcblk1pd (where d is the number of your internal data partition) to mmcblk1p3.
4. You also need to unpack the boot.img, find the fstab.nick in the ramdisk (nick is the nickname of your device) and edit the sysyem, data and cache mountpoints to /dev/block/mmcblk1p2, 3 and 4 accordingly.
In some ROMs, the fstab. file plays no important role. In this case you must search inside files ending in .rc in the RamDisk for lines that have to do with the system, data and cache partitions. For example, in HTC One SV stock-based ROMs, you must change [email protected] with /dev/block/mmcblk1p2. Data and cache also follow this pattern.
5. If you need to flash GApps, then you must also modify that updater-script by changing the line run_program("/sbin/busybox","mount","/system"); into mount("ext4","EMMC","/dev/block/mmcblk1p2","/system");
Any other add-on you may want to flash must first be edited as described in steps 4 & 5.
6. Pack and zip everything back and reboot to recovery.
7. Make a backup of your current ROM and flash your modified zip(s).
When you reboot, your device should load your secondary ROM.
To switch back to the primary ROM you need to reflash your primary kernel (from the backup you took). Use dd if=path/backup.boot.img of=/dev/block/mmcblk0pb (where b is your boot partition) and reboot.
To boot back to your secondary ROM, just use the above command to flash the boot.img extracted from your modified ROM.zip. This process can now be done automatically using SwitchROM.sh from 2nd post
If you don't like scripts or terminal commands, another way to flash your boot images is Flashify.
If for any reason your 2nd ROM doesn't boot (e.g you haven't found the right method to pack your boot.img), you can advanced-restore just your primary boot.img from your backup in recovery. This way you'll be able to boot back to your primary ROM which is otherwise unaffected by the procedure.
In order to complete step 4, these links may be a good start:
i) These tools by Modding.MyMind work on my HTC.
ii) These ones by michfood work on my HTC but only unpack my LG boot.img
iii) and this one by berni987654321 packs my LG boot.img (download dualboot_tool.zip at the end of 1st post).
Don't forget to hit "Thanks" on those pages too.
- Be extra careful if your secondary ROM supports OTA updates which are applied through recovery. Only download but NEVER apply them before you tweak the zips as described above. Otherwise they will overwrite your primary ROM!
- Actually, every zip you want to flash to your secondary ROM must be edited first, otherwise it will flash to your primary.
- You can only use your regular custom recovery to flash edited zips to your secondary partitions. You can't use it to backup, restore or wipe them. Those functions will only affect the primary ROM. For this reason, I have created the DBoot Recovery script. For more info, read on to the second post.
Special thanks to @berni987654321 from whom I learned almost everything there is to know about Dual-Boot. This guide is based on his work.