OK, Guys now lets get to the basics.
Define multiboot ?
Answer :- Multiboot is a option that allows you to load multiple roms on one device.You can switch to your old rom if you don't like the new rom with just one click and that too without flashing and wiping .How cool is that!
Warning : Multiboot will work only with kernels' that have kexec patch. Currently, no custom kernel supports kexec. So we'll be using the kernel that munjeni (JB kernel) and DevSwift1 (ICS kernel) provided us. So it's only working for ICS/JB based roms. Also, we hope that in future all kernel developer will patch kexec to their kernels.
Disclaimer :- You will do this at your own risk. Me or any member from XDA will take no responsibility if you brick your device while attempting to do these
Requirements :-
- ADB Connection (Check if you can connect your phone in normal/recovery/fastboot mode) This is important be you go ahead.
- Your phone should be rooted with unlocked boot loader.
- Any text editor except notepad/Wordpad/Microsoft word.
- You should edit all the files in the text editor on your PC with Unix/utf-8 format.
- You should donate me 500 $ lolzzzz ,Guys just kidding ! .
There are two parts in this session part A will guide you to boot your primary rom from the boot menu and part B will guide you to boot secondary the second rom.
Part A) Booting Into Primary Rom:-
Step 1) Configure BootMenu Settings :-
- Create a folder named "bootmenu" in your sd card.
- Inside the folder create a file names "settings.ini".
- Now create a folder inside bootmenu with a name of the rom that you have installed in your phone.
- Now create another folder named "recovery" so that we can get to CWM recovery in boot..
Note :- Do not use space while naming the folders or else bootmenu will show errors.
Now We will edit the settings.ini file. Copy the file to the desktop and open it with a text editor and write these codes.
[rom-1]
menutitle=Stock JB
kernel=/sdcard/bootmenu/StockJB/zImage
ramdisk=/sdcard/bootmenu/StockJB/initrd.gz
cmdline=your_cmdline
[rom-2]
menutitle=CWM Touch Recovery
kernel=/sdcard/bootmenu/recovery/zImage
ramdisk=/sdcard/bootmenu/recovery/initrd.gz
cmdline=your_cmdline
Here is the explanation for for the codes :-
Now We will edit the settings.ini file. Copy the file to the desktop and open it with a text editor and write these codes.
[rom-1]
menutitle=Stock JB
kernel=/sdcard/bootmenu/StockJB/zImage
ramdisk=/sdcard/bootmenu/StockJB/initrd.gz
cmdline=your_cmdline
[rom-2]
menutitle=CWM Touch Recovery
kernel=/sdcard/bootmenu/recovery/zImage
ramdisk=/sdcard/bootmenu/recovery/initrd.gz
cmdline=your_cmdline
Here is the explanation for for the codes :-
- menutitle is a command used so that you will receive a title in the bootmenu,You can name it after the rom that you are using.
- kernel/ramdisk/cmdline these will be extracted from the boot.img file that is provided with the rom .
- Now if you notice we have set paths for kernel/ramdisk/cmdline in the appropriate folders that we created before.
- In this code you will find two settings because we have only 2 Roms,but if you have more roms you can just copy paste the command starting from [rom-2]. and rename it appropriately.
- cmdline :- This is kernel cmdline. You will find it when you extract the boot.img or lernel.elf file.Open the file with a text editor and copy-paste the whole text in your_cmdline in the codes.
- We have already set the Rom-1 as default ,so if you do not choose any option from the bootmenu within 10 sec. Rom-1 will be booted by default.
Step 2) Extracting Boot.img File :-
- Download image_tool.rar from the link below for your device.
- Extract the files and copy to your /system/bin folder.Make sure to give them permission 755 or rwx r-x r-x. Reboot your phone to apply the changes.
- extract your current ROMs' boot.img and copy it to /data/local/tmp folder.
- connect your phone with pc, establish adb connection and follow the given code and press enter after every code.
adb shell
su
cd /data/local/tmp
mkdir boot
kernel_dump ./boot boot.img
We have extracted the kernel(zImage) and ramdisk(initrd.gz) from the boot.img that is provided with the rom.zip package.
Here is the image for your reference:-
This will dump kernel(zImage),ramdisk(initrd.gz) and cmdline to your /data/local/temp/boot folder. In case of elf based kernel change the boot.img with kernel.elf
Here is the image for your reference:-
This will dump kernel(zImage),ramdisk(initrd.gz) and cmdline to your /data/local/temp/boot folder. In case of elf based kernel change the boot.img with kernel.elf
Step 3) Make the Rom ready to Boot :-
- Download the zImage, bootmenu, recovery ramdisk from below for your device.
- We will be using ramdisk(initrd.gz) only from the dumped folder since the kernel(zImage) inside it is not kexec patched
- Extract it, and search for zImage inside it along with another initrd.gz and a modules folder.
- Copy both zImage & initrd.gz from the downloaded folder and paste it in /sdcard/bootmenu/recovery folder that you created earlier
- copy the recently dumped initrd.gz from /data/local/tmp/boot to /sdcard/bootmenu/StockJB that you created
- For zImage copy the appropriate one for ICS/JB from downloads and paste in the appropriate folder.
Here is a look of the folder structure.
/sdcard/bootmenu
Stock_JB
Stock_JB
initrd.gz (from /data/local/tmp/boot folder)
zImage (from downloads)
recovery
initrd.gz (from downloads)
zImage (from downloads)
settings.ini
initrd.gz (from downloads)
zImage (from downloads)
settings.ini
Note: When custom kernel with kexec patch will be released, you will use zImage, initrd.gz from that kernel.
- copy the modules from modules folder and paste it in /system/lib/modules folder.
- Give them permission 644 or rw- r-- r--. Now you have to flash the boot_menu.img to get the menu at startup
- download the boot_menu.img from download section and flash it by fastboot.
- Done
Reboot your device and you'll enter bootmenu. You'll find options for your Stock ROM and CWM Touch Recovery. Simply select your rom and you'll boot into your Primary ROM.
Quote:
Xperia U (JB)
1) packing, unpacking ->image_tools.rar2) zImage. modules, recovery ramdisk -> cwm.rar 3) bootmenu -> boot_menu.img |
Quote:
Xperia Sola (JB)
1) packing, unpacking ->image_tools.rar2) zImage, modules, recovery ramdisk, bootmenu |
Quote:
Xperia Go (JB)
1) packing, unpacking ->image_tools.rar2) bootmenu 3) zImage, modules, recovery ramdisk |
Quote:
Xperia U, Sola, Go (ICS)
1) packing, unpacking -> same as JB2) zImage. modules, -> here 3) recovery ramdisk, bootmenu -> same as JB |
Quote:
Customized Bootmenu, Recovery
http://forum.xda-developers.com/show...&postcount=349 |
Part B ) Booting Into Second Rom :-
Intro :- Here we will create a new partition and you will learn how to boot from these partitions.
Things to be aware of :-
- First if you do these, I'm assuming you've succeeded in booting into primary ROM. If not, please don't do this.
- You need to have some space in your sdcard (depends on your rom size).
- You can't use CWM Touch Recovery (created earlier) in your second ROM. You have to use its' own recovery. But its' recovery also won't work without modification. It'll be discussed in part2.
- You can't flash ROM.zip normally on second ROM. For that you have to modify your updater-script a little bit. It'll be discussed in part 3.
Step 1) Creating Partition in SD card :-
We have to create three separate partition. One for system, one for data & last one for cache since your current roms' data, system, cache won't match with your second rom. Now say you want CM 10.1 as your second rom. It's size is around ~175MB. After unzipped it is ~290MB and with gapps it becomes ~450MB. So we'll create around 600~650MB sized system partition. Always create system with more space otherwise android will fail to boot.
Connect your phone via ADB and type the commands .
adb shell
su
df
You need to know that system is mounted at /dev/block/mmcblk0p10, data is mounted in/dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12 (see screenshot). We need to remember this for future use.
Now to create all partitions do as following after reading the explanation below:
Code :-
##### for system partition only (updated) #####
dd if=/dev/zero of=/sdcard/your_desired_folder/system.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
losetup /dev/block/loop1 /sdcard/your_desired_folder/system.ext4
blkid /dev/block/mmcblk0p10 (this'll give you a UUID)
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U (paste here your UUID) -I 256 /dev/block/loop1
losetup -d /dev/block/loop1
##### for data,cache partition #####
dd if=/dev/zero of=/sdcard/your_desired_folder/data.ext4 bs=4096 count=76800
###### wait till the partitions is created ######
dd if=/dev/zero of=/sdcard/your_desired_folder/cache.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
Alright here is the Explanation :-
"dd" is a command which will create partitions according to the parameters provided by you.
So in these case partition will be created from /dev/zero to /sdcard/your_folder.
Caution not to switch "if" with "of" and "of" with "if", it may brick your device.
"bs" is the blocksize of your new partition and it's default value is 4096KB(4MB). Don't change it. Let's say you want to create data partition with size of 300MB (cause you don't use many apps). So 300/4(block size) = 75 and 75*1024 = 76800. That's the "count" parameter. So modify system, data, cache size according to your needs but make sure that you have enough space to create your desired partition.
"losetup" basically sets up the loop so that you can mount your partition into that loop.
You need to make sure to avoid any partition corruption and check for errors. Reboot your phone to bootmenu and press any key to avoid auto restart. Keep the device in boot menu. Now again check your adb connection and do these:
Code:
adb shell
losetup /dev/block/loop1 /sdcard/your_folder/system.ext4
losetup /dev/block/loop2 /sdcard/your_folder/data.ext4
losetup /dev/block/loop3 /sdcard/your_folder/cache.ext4
##### To pack/unpack ext4 #####
make_ext4fs /dev/block/loop1
make_ext4fs /dev/block/loop2
make_ext4fs /dev/block/loop3
##### To check for error #####
e2fsck -f -y /dev/block/loop1
e2fsck -f -y /dev/block/loop2
e2fsck -f -y /dev/block/loop3
##### for tuning and cleaning up (just loop2 & loop3) #####
tune2fs -o journal_data_writeback /dev/block/loop2
tune2fs -o journal_data_writeback /dev/block/loop3
##### unmount loop and sdcard #####
losetup -d /dev/block/loop1
losetup -d /dev/block/loop2
losetup -d /dev/block/loop3
umount /sdcard
##### reboot #####
exit
adb reboot
Here is the Image for your reference :-
Your new partitions are now ready for booting!!!!
Step 2) Modifying Second Rom's ramdisk:-
while booting into primary rom, we simply put the ramdisk in /sdcard/bootmenu/StockJB without modifying it. Why do we need to modify it for second rom? Well unless modified, all your recoveries will recognise only your primary rom. So If you flash a rom thinking that it'll be installed in second rom, you'll see it got installed in your primary rom!!! So we'll modify the second roms' recovery so that it can use second rom while cwm touch recovery will use primary rom. Two recoveries for two roms
Code :-
##### for system partition only (updated) #####
dd if=/dev/zero of=/sdcard/your_desired_folder/system.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
losetup /dev/block/loop1 /sdcard/your_desired_folder/system.ext4
blkid /dev/block/mmcblk0p10 (this'll give you a UUID)
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U (paste here your UUID) -I 256 /dev/block/loop1
losetup -d /dev/block/loop1
##### for data,cache partition #####
dd if=/dev/zero of=/sdcard/your_desired_folder/data.ext4 bs=4096 count=76800
###### wait till the partitions is created ######
dd if=/dev/zero of=/sdcard/your_desired_folder/cache.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
Alright here is the Explanation :-
"dd" is a command which will create partitions according to the parameters provided by you.
So in these case partition will be created from /dev/zero to /sdcard/your_folder.
Caution not to switch "if" with "of" and "of" with "if", it may brick your device.
"bs" is the blocksize of your new partition and it's default value is 4096KB(4MB). Don't change it. Let's say you want to create data partition with size of 300MB (cause you don't use many apps). So 300/4(block size) = 75 and 75*1024 = 76800. That's the "count" parameter. So modify system, data, cache size according to your needs but make sure that you have enough space to create your desired partition.
"losetup" basically sets up the loop so that you can mount your partition into that loop.
You need to make sure to avoid any partition corruption and check for errors. Reboot your phone to bootmenu and press any key to avoid auto restart. Keep the device in boot menu. Now again check your adb connection and do these:
Code:
adb shell
losetup /dev/block/loop1 /sdcard/your_folder/system.ext4
losetup /dev/block/loop2 /sdcard/your_folder/data.ext4
losetup /dev/block/loop3 /sdcard/your_folder/cache.ext4
##### To pack/unpack ext4 #####
make_ext4fs /dev/block/loop1
make_ext4fs /dev/block/loop2
make_ext4fs /dev/block/loop3
##### To check for error #####
e2fsck -f -y /dev/block/loop1
e2fsck -f -y /dev/block/loop2
e2fsck -f -y /dev/block/loop3
##### for tuning and cleaning up (just loop2 & loop3) #####
tune2fs -o journal_data_writeback /dev/block/loop2
tune2fs -o journal_data_writeback /dev/block/loop3
##### unmount loop and sdcard #####
losetup -d /dev/block/loop1
losetup -d /dev/block/loop2
losetup -d /dev/block/loop3
umount /sdcard
##### reboot #####
exit
adb reboot
Here is the Image for your reference :-
Your new partitions are now ready for booting!!!!
Step 2) Modifying Second Rom's ramdisk:-
while booting into primary rom, we simply put the ramdisk in /sdcard/bootmenu/StockJB without modifying it. Why do we need to modify it for second rom? Well unless modified, all your recoveries will recognise only your primary rom. So If you flash a rom thinking that it'll be installed in second rom, you'll see it got installed in your primary rom!!! So we'll modify the second roms' recovery so that it can use second rom while cwm touch recovery will use primary rom. Two recoveries for two roms
- extract boot.img from your second roms' zip file and place it in /data/local/tmp folder
- if any boot.img or boot folder is present there just delete it
- Then extract the boot.img the same way as we did before
- Then you'll have boot folder in /data/local/tmp.
- Now put the below codes.
cd /data/local/tmp/boot
mkdir ramdisk
cd ramdisk
gunzip < ../initrd.gz | cpio -i -d
By doing this we have extracted the ramdiskfolder inside the boot folder. Now copy the ramdisk folder onto your desktop.
We will be looking for the following 4 files:-
init.rc
fstab.st-ericsson
recovery.fstab
init.st-ericsson.rc
Once you have located them we will be modifying them one by one.
For Jelly Bean Ramdisk :-
init.rc
Quote:
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
fstab.st-ericsson
Quote:
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/block/mmcblk0p6 /modemfs ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop1 /system ext4 ro wait
/dev/block/loop2 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop3 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
recovery.fstab
Quote:
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat/dev/block/mmcblk0p14
/external_sd vfat/dev/block/mmcblk1p1 /dev/block/mmcblk1
init.st-ericsson.rc
Quote:
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
setprop ro.crypto.state unsupported
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw wait
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
exec /sbin/e2fsck -y /dev/block/loop2
mount_all fstab.st-ericsson
# SEMC: Start the TrimArea Daemon and early TA-users
For ICS Ramdisk:-
fstab (if doesn't exist, ignore it)
Quote:
# These declarations must match the mount statements in
# <buildroot>/device/semc/riogrande/files/init.riogrande.rc
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/modemfs ext4 /dev/block/mmcblk0p6
init.rc
Quote:
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
recovery.fstab
Quote:
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat /dev/block/mmcblk0p14
#/sd-ext ext4 /dev/block/mmcblk0p2
/emmc vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1
init.st-ericsson.rc
Quote:
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
# Wait for eMMC device to become available
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
# Mount system partition
mount ext4 /dev/block/loop1 /system ro
# Mount user data partition
exec /system/bin/logwrapper /system/bin/e2fsck -y /dev/block/loop2
setprop ro.crypto.state unsupported
mount ext4 /dev/block/loop2 /data nosuid nodev noatime noauto_da_alloc
# Mount cache partition
mount ext4 /dev/block/loop3 /cache nosuid nodev noatime
mount ext4 /dev/block/mmcblk0p6 /modemfs nosuid nodev noatime
# FOTA must be started after partitions are mounted
# and property service is initialized
exec /sbin/fota-ua c
Now save & copy these modified files to your /data/local/tmp/boot/ramdisk folder.
Now Open Cmd and type the following
cd /data/local/tmp/boot
mkbootfs ./ramdisk | gzip > initrd.gz
this'll repack the ramdisk folder into initrd.gz and save it in /data/local/tmp/boot folder. Make a new folder in your /sdcard/bootmenu for the new rom and copy this initrd.gz to that folder. Also copy the appropriate zImage for ICS/JB and paste it here. Add a new rom settings in settings.ini for this rom. Now you've your ramdisk ready and modified for flashing zips in second rom
Step 3) Almost Done.:-
- Now we just have to modify your "rom.zip"s updater-script so that it flashes the rom in your newly created partition.
- Extract your updater-script, open it with editor.
- Remember that we saw system is in /dev/block/mmcblk0p10, data in /dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12.
- Find all the lines that start with "format" or "mount" (example format("ext4", "EMMC", "/dev/block/mmcblk0p10", "0")) and replace the /dev/block/mmcblk0p10 with /dev/block/loop1, /dev/block/mmcblk0p11 with /dev/block/loop2 and /dev/block/mmcblk0p12 with /dev/block/loop3.
- Also remove the function that flashes the kernel.
- It's usually at the end of the script. Just search for kernel.elf or boot.img and delete that function.
- Save the updater-script and push it into the zip with winrar. Choose compression "store".
NOTE: If you forget to remove the kernel function then don't worry. It just removes your bootmenu when you flash the second rom. Just power off the device after flashing and flash boot_menu.img again by fastboot.
Now reboot to bootmenu, your second roms' title that you defined in settings.ini will appear here. Select it, then phone will restart and load your second rom. Press vol. down repeatedly to enter its' recovery. From there flash your second rom. Reboot again to bootmenu and select second rom again. Now you'll see second ROM BOOTING
F.A.Q
1.Are you the one to invent this methos?
Ans : No, I am just a guide the whole credit goes to @munjeni for this feature /@DevSwift1 for providing ICS kexec patched kernel and @NoobCoder for the guide.
2.Will this work on GB,ICS ?
Ans: Now Working For ICS based ROM too. See this post for kexec patched kernels ICS kernel with kexec support
For GB, you have to wait for kernel.
3.How can I remove the second ROM ?
Ans: Make sure you are in primary ROM, then just delete the 3 partitions from sdcard.
4.Can't unmount sdcard: device or resource busy
Ans: Type fuser -km /sdcard. It'll kill all the process that's keeping your sdcard busy. Then unmount sdcard.
5.Getting status 7 error ?
Ans: Delete assert function from updater-script.
6.Wifi's not working even after flashing modules from attachment ?
Ans: Unpack initrd.gz and see if there's a lib/modules folder inside it. If it exists and deep inside there are 2 modules, then you need to replace them with the ones from attachment.
7.Getting status 6 error no matter what ?
Ans: Always edit files in unix/utf-8 format and use compression method store to push files in zip. NEVER USE DOS FORMAT.
8.Getting "something went wrong. please see log!" in bootmenu ?
Ans: You have done something wrong in settings.ini or folder naming. Check again.
No comments:
Post a Comment