[Experimental] Dual Boot and above Discussion

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Alright so I have achieved Dual Boot :victory:
THIS IS NOT KEXEC .

It's a simple hack or probably an elegant one.
We can probably achieve multiboot but that is not important.

There are some other things which will be ironed out but thats for later.

Thread Rules :
No Thank you or How Do I do it or nooby questions.
This thread is exclusively for Developers, Enthusiasts and/or Professionals.
Knowledge of Linux and Terminal is MANDATORY.
Dual Partitioned SD card. Second partition preferably
Linux Installed on your computer.

Rubbish posts will be removed .
Save some pride by not being a n00b.


Currently I have planned two types in my mind.

Type 1: Dual Booting ROMs with Same Boot Images - Completed

This hack works across ROMs which use same kernel with same ramdisk... ICS ROMs series , LXP ROMs who use the LXP kernels.. If there is even slight difference in the ramdisk (esp. the init.rc) ,you wont be able to boot ROMs.


Type 2: Dual Booting ROMs with Same kernels but different Ramdisks- Therotically completed.

Post 1: Intro
Post 2: Prepare SD Card and Images
Post 3: Prepare Ramdisk and ROM Installations
Post 4: Installation and switching ROMs
Post 5:Ramdisk Mod
Post 6 : Multiple Mounts/ MultiBoot
Post 7: FAQ
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Problems :
Partitioning SD card is annoying and not fruitful
Second SD card partition might be used as second SD card on First ROM.

Solution"
Use loop Images.

I WOULD RECOMMEND USING ANY LINUX DISTRO FOR MAKING A LOOP IMAGE. Because LINUX !!!

Preparation:

Dump Images and formatting.

Make dump images
Code:
dd if=/dev/zero of=system.kdpr bs=4096 count=100000
Will you give you 400 MB image
Code:
dd if=/dev/zero of=data.kdpr bs=4096 count=200000
Will you give you 800 MB image.

Mount Images (as root)
Code:
losetup /dev/loop0 system.kdpr
Code:
losetup /dev/loop1 data.kdpr
Format images(as root)
Code:
sudo mkfs.ext4 -T ext4 -b 4096 -m 0 -J size=4 -O ^huge_file,^has_journal,^resize_inode,^ext_attr /dev/loop0
sudo mkfs.ext4 -T ext4 -b 4096 -m 0 -J size=4 -O ^huge_file,^has_journal,^resize_inode,^ext_attr /dev/loop1
tune2fs -c 100 -i 100d -m 0 /dev/loop0
tune2fs -c 100 -i 100d -m 0 /dev/loop1
You have two ext4 formatted images system.kdpr and data.kdpr ready.
Copy those images to sd-ext folder.You can mount /dev/mmcblk0p2 on a folder and directly push these images via adb push
OR copy images to SD card and copy to second partition.
Either way the system.kdpr and data.kdpr should be in root of the second SD card partition.

Assuming you have mounted second sd card partition on /data/sd-ext.

Run this command
Code:
touch flag_kdpr
The Images are now ready and loaded :victory:
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Now is the time to hack the boot image.
Unpack Boot image and navigate to ramdisk folder

Navigate to the lines in init.rc where partitions are mounted .
Comment off or remove the lines mounting system and data
For stock ICS it is in init.semc.rc
Code:
 #mount yaffs2 [email protected] /system
    #mount yaffs2 [email protected] /system rw remount
    #mount yaffs2 [email protected] /data nosuid node
v

add a line
Code:
exec /sbin/mount_fs.sh
now create a bash script named mount_fs.sh as follows

Bash:
#!/sbin/sh

mount /dev/block/mmcblk0p2 /res/sdext
flag_boot=`cat /res/sdext/flag_kdpr`

if [ ${flag_boot} -eq 1 ]
then
mount /res/sdext/system.kdpr /system
mount -o remount,rw /res/sdext/system.kdpr /system 
mount /res/sdext/data.kdpr /data
else
mount /dev/block/mtdblock0 /system
mount -o rw,remount /system
mount /dev/block/mtdblock1 /data
fi
make a folder named /res/sdext or choose mount point of your choice

We will be controlling the mount point and boot via the file flag_kdpr.
Using this flag we can also achieve MultiBoot

Repack the boot image.
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Installing Secondary ROM

Open the zip and extract the updater script .
Remove the lines for mounting/formatting system and data.
Repack the zip

Mount sd-ext
Run these commands in terminal

Code:
mount /sd-ext/system.kdpr /system
mount /sd-ext/data.kdpr /data
Install the zip ROM.
ROM will be installed in the dump images.

Booting to secondary ROM:
In the recovery or first ROM run this command

Code:
echo 1 > /sd-ext/flag_kdpr
OR
Code:
echo 1 > /res/sdext/flag_kdpr
and reboot

Booting to primary ROM:
In the recovery or first ROM run this command

Code:
echo 0 > /sd-ext/flag_kdpr
OR
Code:
echo 0 > /res/sdext/flag_kdpr
and reboot
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Stage 2 : Ramdisk Mod .

This is actually theoretical, but it should work anyway. @nobodyAtall 's recovery for locked bootloader works in a similar fashion.
This is for LXP+ kernels or kernels who use init.sh to load the ramdisk archives.

Steps .
Preparation :
SD Card

Add a folder named ramdisk in root of second SD card
Code:
mkdir ramdisk
Add ramdisks in this folder

Add a flag for ramdisk
Code:
touch flag_ramdisk
Make a script mount ramdisk.sh

Bash:
#!/sbin/busybox sh

flag_ramdisk=`cat /sdext/flag_ramdisk`

if [ ${flag_ramdisk} -eq 1 ]
then

busybox cpio -i < /sdext/ramdisk/abc_ramdisk.cpio

elif [ ${flag_ramdisk} -eq 2 ]
then

busybox cpio -i < /sdext/ramdisk/pqr_ramdisk.cpio

else

busybox cpio -i < /sbin/ramdisky.cpio
fi
Ramdisk of Primary kernel

Edit init.sh
create directory
Code:
mkdir -m 755 -p /sdext
Mount second SD card partition before loading the ramdisk
Code:
mount /dev/block/mmcblk0p2 /sdext
Comment or delete the line loading kernel.
Replace/add with
Code:
busybox sh /sdext/ramdisk.sh
Unmount Second sd card

Ramdisk will "theoretically" load.
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Handling Multiple Ramdisks and Multiple Mounts.

Multiple Ramdisk mod is useful when.
  • You have to test a new ramdisk
  • You have to run alternative ROM on a same kernel(e.g MIUI)
  • Load custom recovery for alternative mount points (CM12 ,Secondary ROM)

Dual/Multi ROM is useful for
  • Alpha/Beta testing
  • For the lulz

Both of these mods are independent of each other.

You can use Primary Ramdisk with Ramdisk mod and Secondary Ramdisks with mount mods

Multi Boot is similarly implemented. Except you need lot of space in second partition ,each around 1-1.5 GB per system-data combo.
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Some "friendlier" ways to dual Boot.

Method 1
Noob Friendly Instructions for Dual Boot.
I have done most of the heavy lifting
You need to flash the kernels above first.
Currently only Radium is supported for primary ROM.
But you can install ANY ICS ROM as secondary.


Requirements :
  • Basic Notepad Skills.
  • Dual Partition SD card Exceeding 1.2GB atleast.
  • Battery % atleast above 70%
  • Patience

Download

https://www.mediafire.com/folder/aiv828ivuumrk/Dual_Boot_Zips

Download all zips in this folder.

Definition

Dual_Boot_Install_400.zip : 400MB system + 400 MB data
Dual_Boot_Install_600.zip : 400 MB system + 600 MB data
Dual_Boot_Install_800.zip : 400 MB system +800 MB data
Mount.zip : To Mount The secondary system/data before installing ROMs
prim.zip : Boot to Primary ROM
sec.zip :Boot to Secondary ROM

Setup Dual Boot:

  • Go to recovery
  • Go to mounts & storage
  • Format sd-ext
  • Flash any ONE of the Dual_Boot_Install_Zips
  • Patience part comes here. Depending on how your SD card is ,it takes 5-10 minutes to copy.

ROM Preparation
Extract the updater script of your ROM zip in your desktop.
Open it in notepad++
Delete the lines mounting and formatting system and userdata like these
unmount("/system");
format("MTD", "system");
mount("MTD", "system", "/system");
Copy back the updater script in the ROM folder
Copy ROM to SD card

ROM installation:
Run Mount.zip
Run The ROM installer
Finished


Before Installing Zips below ,Make sure sd-ext is NOT mounted in mounts and storage.

Booting to primary ROM
Run the primary.zip in recovery OR
OR
mount sd-ext and run
Code:
echo 0 > /sd-ext/flag_kdpr
in adb shell

Booting to secondary ROM
Run the secondary.zip in recovery.
OR
mount sd-ext and run
Code:
echo 1 > /sd-ext/flag_kdpr
in adb shell

Those huge blank images can be fit in such a small zip file. There is no data so it can be compressed to the Max.


Method 2


Even more easier Dual ROM installation. This type of stuff can only be achieved on the Zero Layout

Noob Friendly Instructions for Dual Boot.


Requirements :
  • Dual Partition SD card Exceeding 1.2GB atleast.
  • Battery % atleast above 70%
  • Patience

Download

https://www.mediafire.com/folder/aiv828ivuumrk/Dual_Boot_Zips

Download all zips in this folder.

Definition

Dual_Boot_Install_400.zip : 400MB system + 400 MB data
Dual_Boot_Install_600.zip : 400 MB system + 600 MB data
Dual_Boot_Install_800.zip : 400 MB system +800 MB data
Mount.zip : To Mount The secondary system/data before installing ROMs
prim.zip : Boot to Primary ROM
sec.zip :Boot to Secondary ROM
clone2.zip :cloning Primary ROM to Secondary ROM

Setup Dual Boot:

  • Go to recovery
  • Go to mounts & storage
  • Format sd-ext
  • Flash any ONE of the Dual_Boot_Install_Zips
  • Patience part comes here. Depending on how your SD card is ,it takes 5-10 minutes to copy.

ROM INSTALLATION :


  • Install Secondary ROM as you install any ROM
  • Finish installation
  • Don't reboot.
  • Mount sd-ext in mounts and storage
  • Flash clone2.zip
  • [optional]Watch Anime
  • After installation finished
  • Install Primary ROM.
  • Finish Installation

Clone Zip basically clones your running ROM as secondary ROM. This stuff beats nandroid backup !!





Booting to primary ROM
Run the primary.zip in recovery OR
OR
mount sd-ext and run
Code:
echo 0 > /sd-ext/flag_kdpr
in adb shell

Booting to secondary ROM
Run the secondary.zip in recovery.
OR
mount sd-ext and run
Code:
echo 1 > /sd-ext/flag_kdpr
in adb shell

Those huge blank images can be fit in such a small zip file. There is no data so it can be compressed to the Max.
 
Last edited:

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
Lagfix after a while.
After 5-7 boots , Secondary ROM starts lagging.
fsck is needed to be performed from the reccovery to fix lag.

Commands :
Code:
e2fsck /res/sdext/data.kdpr
e2fsck /res/sdext/system.kdpr
Or just add it to mount scripts before mounting.
 
  • Like
Reactions: rahulbarai

karandpr

Space too small for my titles. Check Signature
Staff member
Feb 20, 2011
9,688
13,151
263
Prolific Troll
@karandpr,is there any possibility to dualboot some roms with different kernel layout or version (like multiboot on newer phone)? :D
Nope. On fly layout change is impossible.
Even when you change layout ,you need a fastboot erase ,or the consequences can be weird.

Version change is possible.
anonymous had a kernel which can boot ICS , CM9 ,CM 10 & MIUI JB.
Multiboot off his hybrid kernel is very possible.

I am exploring the possibility of Kitkat and lollipop since both are versions 3.4 . Not sure if it can happen but worth a risk.