Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,729,145 Members 41,442 Now Online
XDA Developers Android and Mobile Development Forum

[HOWTO] Dual-Boot P31xx

Tip us?
 
Nicene Nerd
Old
(Last edited by Nicene Nerd; 5th September 2012 at 02:45 PM.)
#1  
Nicene Nerd's Avatar
Senior Member - OP
Thanks Meter 160
Posts: 220
Join Date: Mar 2012
Location: Chattanooga

 
DONATE TO ME
Talking [HOWTO] Dual-Boot P31xx

Dual-booting has always intrigued me. I dual-boot between Windows and Linux on one of my computers, dual-boot between stock firmware and RockBox on my Sansa Fuze v2, and I decided to find out how to dual-boot my Galaxy Tab 2 7.0". It took a couple days of work, but I have found one way to do so using the external SD card.
In the future, if I can work it out, I will provide a method for dual-booting using only internal storage. Update: I have successfully tested an internal dualboot setup. I will post details later.
Warning: While I am not aware of any specific way this could brick your device, stuff happens, so don't blame me. I've tested this and found no problems, but you may not be the same.
To use this method, you need a microSD card at least 8GB in size. If you use 8GB, though, you will have pretty limited space for storage, so a card 16GB or greater is advised.
Preparing SD Card
  1. Repartition your microSD card using whatever program suits you. You need to shrink the first storage partition to make room for the new system partitions. The new partitions should take at least 5GB, so be sure to leave at least 5.25GB. You can always resize later if you need to.
  2. After shrinking your storage partition, create four ext4 partitions in this order: system (min 800MB, recommended 1.25GB), cache (min 500MB, recommended 700MB), data (min 3GB, recommended 5GB), and EFS (min 21MB, recommended 32MB).
  3. Verify your partitions on your tablet by inserting the SD card, booting into CWM, and running "parted /dev/mmcblk1" (no quotes) over ADB shell.
Flashing External ROM
  1. Now you just need a ROM to flash. Most ROMs are not packaged to run from external SD card. You MUST either use a provided ROM or edit one yourself. I provide here a repackaged version of the 8/28 CM10 nightly which can flash to and run from your SD card. If you want to edit a ROM yourself, see the bottom of this post.
  2. Boot into CWM and backup. You will need your backed up boot image if anything goes wrong.
  3. Now flash your ROM. It will install to the external SD card on the appropriate partitions if you did everything right. Reboot: you should be in your new ROM.
  4. You'll probably want a Google Apps package. See below for packages for external dualboot.
Using Your Dual-Boot Setup
  • Your internal and external ROMs do not share internal storage, due to the odd nature of the SD card fuse tool.Your external ROM has an "internal SD card" of its own. You may find a way to mount the internal /data/media to the external ROM's /sdcard. My new ROM conversion script will add attempt to mount the internal ROM's storage to /storage/intSdCard
  • The ROMs I provide here include a script in /system/bin called "bootinternal." Run this from a terminal emulator or adb to switch from the external ROM back to the internal one. I have attached a script called "bootexternal" to this post. Use it on your internal ROM to switch to the external one (remember to set the executable permission).
  • In order for the boot switching scripts to work, you must do some preparation. On your external ROM, place the internal ROM's boot.img in /sdcard/Boot/internal.img. For your internal ROM, place your external ROM's boot.img in /sdcard/Boot/external.img.
  • If you ever need/watch to switch ROMs manually, run the following commands in a terminal emulator or over ADB, replacing "boot.img" with the boot image of the ROM you are switching to:
    Code:
    cat boot.img > /dev/block/mmcblk0p5
    reboot
    Alternatively, you could switch boot images using Mobile Odin.
  • Update: I would skip using my prepackaged ROMs now, because I have uploaded a converter script that will actually do a better job. These will configure the "bootinternal" and "bootexternal" scripts automatically.
  • If you ever need to wipe your data, cache, or dalvik cache, see the next post for CWM zips.
Downloads
Roms for External SD Card:
CyanogenMod 10 Nightly (8/28/2012)
AOKP P3113 Stable
Note that these are probably unnecessary now, because I provide a script to convert ROMs automatically on Linux.
Google Apps Packages for External SD Card:
Gapps for Jelly Bean - Use for CM10, AOKP, etc
Gapps for Ice Cream Sandwich - Use for stock, RomsWell, etc
If I ever have time, I plan to upload SD card images which you can use to partition your external SD card automatically.
---
Repacking a ROM for Dual-boot from SD Card
Note: You no longer need to do this manually. I have uploaded a script which automates the conversion process. See the next post for download.
  1. First, you need to extract and unpack the boot image. There are tools and scripts available for this, so find one.
  2. Once the boot image is unpacked, you need to edit init.espresso.rc on the ramdisk. Find where the partitions are mounted and change the code to look like this (yours may look slightly different depending on the ROM, but just be sure to replace the default partition mounts with those of your SD card partitions):
    Code:
        #mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS /system wait rw   
        mount ext4 /dev/block/mmcblk1p2 /system wait rw
        #mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS /system ro remount
        mount ext4 /dev/block/mmcblk1p2 /system ro remount
        #mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/DATAFS /data wait noatime nosuid nodev crypt discard,noauto_da_alloc
        mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/DATAFS /data2 wait noatime nosuid nodev crypt discard,noauto_da_alloc
        mount ext4 /dev/block/mmcblk1p4 /data wait noatime nosuid nodev crypt discard,noauto_da_alloc
        #mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/CACHE /cache wait noatime nosuid nodev nomblk_io_submit,errors=panic
        mount ext4 /dev/block/mmcblk1p3 /cache wait noatime nosuid nodev nomblk_io_submit,errors=panic
        #mount ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/EFS /efs wait rw
        mount ext4 /dev/block/mmcblk1p5 /efs wait rw
  3. Repack the boot image and stick it back into the ROM. Then edit the updater-script, and change all references to the internal system partition (/dev/block/mmcblk0p9) to the external system partition (e.g. /dev/block/mmcblk1p2). If any other partitions are referenced, change them as well.
  4. Optional: insert the "bootinternal" script in /system/bin and the a script to mount the internal storage in /system/etc/init.d.
  5. Your ROM is ready to go. Flash and be happy!

Thanks to Johnsel for helping me edit the boot image and pointing me to sendust7's work on the Atrix, who I also thank for his precedent.
Attached Files
File Type: txt 02intsdcard.sh.txt - [Click for QR Code] (122 Bytes, 389 views)
File Type: txt bootexternal.sh.txt - [Click for QR Code] (81 Bytes, 322 views)
File Type: txt bootinternal.sh.txt - [Click for QR Code] (81 Bytes, 238 views)
The Following 37 Users Say Thank You to Nicene Nerd For This Useful Post: [ Click to Expand ]
 
Nicene Nerd
Old
(Last edited by Nicene Nerd; 4th September 2012 at 06:54 PM.)
#2  
Nicene Nerd's Avatar
Senior Member - OP
Thanks Meter 160
Posts: 220
Join Date: Mar 2012
Location: Chattanooga

 
DONATE TO ME
Default CWM Zips for Wiping External Partitions

If you ever need to wipe /data, /cache, or dalvik on your external dual-boot partitions, you can use these CWM zips to do so.

Update: Here is a script to automate the conversion of a ROM from standard to external dualboot.
Attached Files
File Type: zip wipe-cache-dualboot.zip - [Click for QR Code] (152.3 KB, 280 views)
File Type: zip wipe-dalvik-dualboot.zip - [Click for QR Code] (152.4 KB, 265 views)
File Type: zip wipe-data-dualboot.zip - [Click for QR Code] (153.4 KB, 265 views)
File Type: zip dualboot-rom-convert.zip - [Click for QR Code] (18.8 KB, 386 views)
The Following 12 Users Say Thank You to Nicene Nerd For This Useful Post: [ Click to Expand ]
 
baliriot
Old
#3  
baliriot's Avatar
Senior Member
Thanks Meter 265
Posts: 741
Join Date: Nov 2010
Location: Shah Alam
interesting... gonna try this later...
 
scottx .
Old
#4  
scottx .'s Avatar
Senior Member
Thanks Meter 767
Posts: 2,194
Join Date: Jun 2011
Location: San Antonio, Texas
Nice guide! Dual boot with stock and cm9/10/AOKP would be ideal.
Google Nexus 4 (16gb, mako (rev_11))
Google Nexus 7 (2013) (16gb, flo)
LG G2 (32gb, D-801)

M. Scott @ Google Play. (Zooper Skins)
 
F3AR420
Old
#5  
F3AR420's Avatar
Senior Member
Thanks Meter 54
Posts: 278
Join Date: Oct 2011
Location: in a house
Confirmed?

Sent from my GT-P3113 using Tapatalk 2
Samsung Galaxy S III Custom ROM
 
IFLATLINEI
Old
#6  
IFLATLINEI's Avatar
Senior Member
Thanks Meter 44
Posts: 215
Join Date: Dec 2010
Quote:
Originally Posted by scottx . View Post
Nice guide! Dual boot with stock and cm9/10/AOKP would be ideal.
Agreed! Is it possible to dual boot stock and AOKP?
 
Nicene Nerd
Old
#7  
Nicene Nerd's Avatar
Senior Member - OP
Thanks Meter 160
Posts: 220
Join Date: Mar 2012
Location: Chattanooga

 
DONATE TO ME
Quote:
Originally Posted by IFLATLINEI View Post
Agreed! Is it possible to dual boot stock and AOKP?
Absolutely. If you're running stock, just follow the instructions to partition your SD card, then flash the provided AOKP package and (I assume you would) the gapps package. You should boot right into to your external AOKP installation. Then just copy your stock boot image to /sdcard/Boot/internal.img and run "bootinternal" from a Terminal Emulator or adb shell to return to stock.
The Following User Says Thank You to Nicene Nerd For This Useful Post: [ Click to Expand ]
 
silentvisitor
Old
#8  
Senior Member
Thanks Meter 509
Posts: 1,251
Join Date: Mar 2012
BRILLIANT !!!

A few suggestions:
Possible to have a GUI to switch ROM or even better to have it at boot (through kernel).
Script to Automate the process of converting any(P31xx) ROM to dual-boot. It will take away pressure off you.

Thanks !
 
john9
Old
#9  
Account currently disabled
Thanks Meter 269
Posts: 1,587
Join Date: Oct 2011
thanks for the tutorial.
 
Nicene Nerd
Old
#10  
Nicene Nerd's Avatar
Senior Member - OP
Thanks Meter 160
Posts: 220
Join Date: Mar 2012
Location: Chattanooga

 
DONATE TO ME
Quote:
Originally Posted by silentvisitor View Post
BRILLIANT !!!

A few suggestions:
Possible to have a GUI to switch ROM or even better to have it at boot (through kernel).
Script to Automate the process of converting any(P31xx) ROM to dual-boot. It will take away pressure off you.

Thanks !
The GUI may or may not happen, since I, while familiar with partitions and scripting, don't know much about Java or Android development. I'll look into it, though. Having it run at boot through the kernel is beyond my skills. The closest I could do would be an init.d script.
As for a script to automate the conversion process, that seems doable. It only involves two files (init.espresso.rc in the boot image and the updater-script), so I could see that happening. I'll try to do something with that.

The Following 2 Users Say Thank You to Nicene Nerd For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes