[Experimental] Dual Boot and above Discussion - Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A

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

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:

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.

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

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.

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.

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");
Click to expand...
Click to collapse
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.

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.

@karandpr,is there any possibility to dualboot some roms with different kernel layout or version (like multiboot on newer phone)?

ryanrinaldhi said:
@karandpr,is there any possibility to dualboot some roms with different kernel layout or version (like multiboot on newer phone)?
Click to expand...
Click to collapse
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.

Related

Merged Thread, Swap file, Multiple Partitions

This is a merged thread, from the two previous posts I created, both questions I awnserd myself. here is the awnser you really want multiple partitions for your phone
First you must run gparted from command promp on your computer, so connect your phone to your computer and run in the terminal:
Code:
adb shell
parted /dev/block/mmcblk0
print
remove any partitions
Code:
rm1
rm2
rm3
rm4
rm5
now create new partitions these partitions should be as so, for sense or 2.1, or gingerbread roms fat32 ext2 swap file is the order, for froyo I believe it is swap ext2 fat32, but I have not tried a froyo rom yet.
Code:
mkpartfs primary fat32 0 14500MB
mkpartfs primary ext2 14500MB 15500MB
mkpartfs primary linux-swap 15500MB 15900MB
now push swap.zip file from below to your phone, and flash swap.zip
now reboot
now open terminal emulator and type:
Code:
ls /dev/block/
this should print something like this:
mmcblk0p1
mmcblk0p2
mmcblk0p3
mntblock1
mntblock2
loop1
loop2
the mmcblk0p'# are the sdcard partitions
to mount the fat32 partition type:
Code:
mount -o rw -t vfat /dev/block/mmcblk0p1 /mnt/sdcard/
now use one of SwapScriptv2.1.1 thanks to cyanogen
type in terminal:
Code:
[B]swapscriptv2[/B]
Follow the prompts and you should see your new swap partition in use, by typing:
Code:
[B]free[/B]
in your terminal now if you woud like to have the swap started at boot time type
Code:
[B]bootswapv2[/B]
rd
and follow the prompts after this you should have a new 3 partitioned sdcard fat32 ext2 and swap and using and mounted on fat32 on sdcard and swap running
using the ext2 will be for either cach2cach appsor maybe linux, I have not decied yet
http://forum.cyanogenmod.com/topic/208-swap-enabledisable/
Flash from Recovery
Compatible with 2 and 3 partition layouts (ext(fat+ext+swap) and no ext(fat+swap))
http://www.mediafire...qdvxh7sos5svcvc
or
http://www.sendspace.com/file/h66oap
This script adds commands to terminal:
Code:
swapscriptv2
bootswapv2
swap-off
bootswap-off
vmtweaks
vmtweaks-boot
swapscriptv2 - you will be asked what partition layout you are using as well as swappiness, optional vm settings prompted
bootswapv2 - you will be asked what partition layout you are using as well as swappiness, and an init script will be placed for swap at boot time, optional boot time vm settings prompted
swap-off turns off active swap partition (error for parition not in use is normal)
bootswap-off removes bootswap init file.
vmtweaks allows changing settings for vfs_cache_pressure and page-cluster, some people have reported success in reducing these values.
vmtweaks-boot allows changing settings for vfs_cache_pressure and page-cluster and applying them at boot.
Let me know if there are any problems with the new script.
the following commands in the terminal
SwapScript: (v1)
Flash from Recovery
fat32+ext+swap or swap on /dev/block/mmcblk0p3
http://www.mediafire...bnc79k6pkespzbj
fat32+swap no ext or swap on /dev/block/mmcblk0p2
http://www.mediafire...b3ykdk3r21js96q
This script adds several commands to terminal:
swapon10
swapon20
swapon30
swapon40
swapon50
swapon60
swapon70
swapon80
swapon90
bootswap10
bootswap20
bootswap30
bootswap40
bootswap50
bootswap60
bootswap70
bootswap80
bootswap90
swap-off
bootswap-off
Instructions
swaponXX (20,30,40,50,60) - will result in swap being turned on with a swappiness of XX
bootswapXX (20,30,40,50,60) - will enable swap at boot time with a swappiness of XX (no usuerinit.sh needed)
swap-off - Turns running swap off.
bootswap-off - removes init swap script from boot. (see above notes for removal if you used the newer script)
SWAPFILE CREATOR:
http://www.mediafire...yr7w2yd5sfobyte
For anyone interested in testing different swap sizes and swappiness or those with no partition other than the standard fat, I threw together a swapfile script allowing for several common configurations. Similar to my swapscript after flashing from recovery a number of new commands will become available in terminal:
Instructions
First create a swap file on your sdcard or sd-ext partition:
swapfileXX (size 12,24,36,64,96,128 on sdcard fat partition)
extswapXX (size 12,24,36,64,96,128 on sdcard ext partition)
Then set swappiness:
swpXX (XX is swappiness in increments of 10 up to 90)
errors in script are normal, script references both fat and ext locations, will fix this next update
swapfile-off (stop swap file in use)
errors in script are normal, script references both fat and ext locations, will fix this next update
clearswapfile (stops swap file and removes all swap files created)
errors in script are normal, script references both fat and ext locations, will fix this next update
Swapfile at boot ONLY SUPPORTED FOR SWAPFILE ON EXT:
bootswapfileXX (XX is swappiness in increments of 10 up to 90)
bootswapfil-off - removes bootswap
SwapFileScript:
http://www.mediafire...yr7w2yd5sfobyte
How to tell if swap is currently in use:
in terminal emulator or adb shell type 'free' with no 's and press enter
if there is a number in the space that says swap you have swap enabled

[GUIDE][U, SOLA, GO, P][ICS/JB][Unlocked BL] Enable Multi Boot Feature

Hello Guys,
This is my first thread in XDA and probably the most important one too. As the title says, I would like to introduce the awesome multiboot capabilities of Xperia U, Sola, Go, P developed by our favourite dev munjeni . Here is the original thread http://forum.xda-developers.com/showthread.php?t=2418241. Go there & give thanks to him for this awesome feature.
UPDATE: September 20, 2013
Made it to the Portal Homepage!!!!
Thanks all for your constant support for updating this thread and thanks to munjeni without whom this feature would've been just a dream
Portal Link: http://www.xda-developers.com/android/enable-multi-boot-on-the-xperia-u-sola-go/​
Click to expand...
Click to collapse
So, What is Multiboot ?
Ever got tired of flashing ROM again & again because of bootloop or to choose a good ROM?? Well news flash, now u don't have to. U can install multiple operating system in your ROM just like you do in your computer. Don't like the new ROM? Just switch your ROM to previous one with just a click. No flashing, wiping needed. The secondary ROM will be loaded from the sdcard partition.​
WARNING: Your warranty is already void. You will do this at your own risk. Me or XDA will take no responsibility if you brick your device while attempting to do these.
Requirements
ADB connection. Please check if you can connect adb in normal mode, recovery mode, fastboot mode. It's mandatory.
Rooted phone with unlocked bootloader
Any text editor except notepad, microsoft word or wordpad.
It is recommended to edit all files in PC with text editors and with unix/utf-8 format.
Brain & Brave heart
This is a step by step guide to enable multiboot intended for all users including noobs like me . The whole process is divided into several parts. First I'll guide you to boot your current rom (primary rom) through boot menu. Then I'll cover how to boot the second rom.
So, Let's Get Started !!!!
Booting Into Primary/Current ROM​
Part 1: Configure BootMenu Settings
So, the basic is this: when you power on your device, a menu will appear containing the list of ROMs' you have installed in your device. You browse it and select which ROM you want to boot. Then it'll be loaded. Pretty simple, eh ? But how will this menu figure out which ROM you have in your device? That's right, we have to define them.
Create a folder named "bootmenu" in your sdcard
Inside the folder, create a file named "settings.ini"
Now say you have stock JB 4.1.2 installed. So create a folder inside "bootmenu" named "StockJB". Also we have to create another folder "recovery" so that we have cwm recovery in Boot.
Don't use space while naming the folder. Otherwise bootmenu will show error at startup.
Now we have to edit the settings.ini file. Copy it to desktop and open it with text editor. Write these code....
Code:
[rom-1]
menutitle=Stock JB
kernel=/sdcard/bootmenu/StockJB/zImage
ramdisk=/sdcard/bootmenu/StockJB/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
[rom-2]
menutitle=CWM Touch Recovery
kernel=/sdcard/bootmenu/recovery/zImage
ramdisk=/sdcard/bootmenu/recovery/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
Let's explain these. "menutitle" is the name that'll appear in the menu when you power on the device. kernel, ramdisk, cmdline will be extracted from the boot.img that is provided with the ROM. More info about extracting them will be discussed later. You can see that in the kernel,ramdisk we have to set the path to the StockJB and recovery folder we created earlier. There are 2 rom settings for stock jb & recovery. If you want to have more ROM, you have to add another rom settings here. "cmdline" is kernel command line. You can find it when you extract boot.img or kernel.elf (see part 2). Open it with editor and copy-paste the whole text in your_cmdline. Now, ROM1 here will be the default rom i.e if you don't select any rom to load in 10 seconds, bootmenu will automatically load the ROM1 defined here :good:. After you're done editing simply overwrite the settings.ini with your new settings.ini in bootmenu folder. That's the end of first part. We'll come back to these folder again later.
Part 2: Extracting boot.img
Now we'll dive into more complex steps. We'll extract the kernel(zImage) and ramdisk(initrd.gz) from the boot.img that is provided with the rom.zip package. We'll need some tools to do that. Download the image_tools.rar from download section. Extract the files and copy them 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.
Now extract your current ROMs' boot.img and copy it to /data/local/tmp folder. Now connect your phone with pc, establish adb connection and follow the given code:
Code:
adb shell
su
cd /data/local/tmp
mkdir boot
kernel_dump ./boot boot.img
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
this will dump kernel(zImage), ramdisk(initrd.gz) and cmdline to your /data/local/tmp/boot folder. For elf based kernel, just change the boot.img with kernel.elf.
Part 3: Ready the ROM For Booting
We will be using ramdisk(initrd.gz) only from the dumped folder since the kernel(zImage) inside it is not kexec patched!!! (If zImage is kexec patched, then use that one rather than from download section). Download the zImage, bootmenu, recovery ramdisk from download section. Extract it, you will find 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. Now 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 here. The folder structure will look like these:
/sdcard/bootmenu
Stock_JB
initrd.gz (from /data/local/tmp/boot folder)
zImage (from downloads)
recovery
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.
We're nearly there. Only two thing remains. Since we'll use munjenis' JB kernel(zImage) or DevSwift1s' ICS kernel we need to flash the proper module for that kernel. Otherwise wifi & other module will not work. So 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. That's simple, download the boot_menu.img from download section and flash it by fastboot.
That's it!!! Your current ROM (primary rom) is ready for booting. Reboot your device and you'll enter bootmenu. You'll find options for your Stock JB and CWM Touch Recovery. Simply select your rom and you'll boot into your Primary ROM :laugh::laugh:. Your bootmenu will look like these except you'll have Stock JB option (I'm using SlimBean & CM 10.1 ).
Downloads
Xperia U (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage. modules, recovery ramdisk -> View attachment cwm.rar
3) bootmenu -> View attachment boot_menu.img
Click to expand...
Click to collapse
Xperia Sola (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage, modules, recovery ramdisk, bootmenu
Click to expand...
Click to collapse
Xperia Go (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) bootmenu
3) zImage, modules, recovery ramdisk
Click to expand...
Click to collapse
Xperia P ​Download from this thread http://forum.xda-developers.com/xperia-u/p-development/-t2647623
Click to expand...
Click to collapse
Xperia U, Sola, Go (ICS)​1) packing, unpacking -> same as JB
2) zImage. modules, -> here
3) recovery ramdisk, bootmenu -> same as JB
Click to expand...
Click to collapse
Customized Bootmenu, Recovery​http://forum.xda-developers.com/showpost.php?p=45733631&postcount=349
Click to expand...
Click to collapse
​::Credits::​
@munjeni bro for this awesome feature in our awesome device. ALL HAIL MUNJENI
@DevSwift1 for providing ICS kexec patched kernel
@percy_g2 for his work on Xperia P
Me, for writing this guide
Welcome to the second part of this guide . Here I'll cover how to create partitions in sdcard and from them how to boot the second ROM. Things that you need to know before doing this:
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.
Getting worried? Well, don't be. It's easy if you follow the steps thoroughly :fingers-crossed:
Let's get started!!!
Booting Into Second ROM
From Internal Storage​
Part 1: Creating Partition in SDCARD
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.
Enough talk. Let's jump into action. Connect your phone, establish ADB connection do as the following:
Code:
adb shell
su
df
this'll show all your mounted partitions and their status. See 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:
[B][CENTER]##### for system partition only ([COLOR="red"]Updated[/COLOR]) #####[/CENTER][/B]
[COLOR="Red"]dd if=/dev/zero of=/sdcard/your_desired_folder/system.ext4 bs=4096 count=(your desired size)[/COLOR]
###### wait till the partitions is created ######
[COLOR="Red"]losetup /dev/block/loop1 /sdcard/your_desired_folder/system.ext4
blkid /dev/block/mmcblk0p10 ([COLOR="blue"]this'll give you a UUID[/COLOR])
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U ([COLOR="Blue"]paste here your UUID[/COLOR]) -I 256 /dev/block/loop1
losetup -d /dev/block/loop1[/COLOR]
[B][CENTER]##### for data,cache partition #####[/CENTER][/B]
dd if=/dev/zero of=/sdcard/your_desired_folder/data.ext4 bs=4096 count=[COLOR="Blue"][B]76800[/B][/COLOR]
###### 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 ######
Ok, let's explain these. "dd" comand will create partition based on the parameter given by you. So in these case partition will be created from /dev/zero to /sdcard/your_folder. Be careful, don't switch "if" with "of" and "of" with "if", it may brick your device. Notice that there are some other parameters. "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.
Update: You can now create system partition with exact amount of size instead of cloning them ( big thanks to munjeni again ). Before, creating specific sized system partition caused bootloop cause it was missing an unique identifier (UUID). Now it has been fixed (marked with red code).
Now comes more complex steps. 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 ([COLOR="red"]just loop2 & loop3[/COLOR]) #####
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
That's it!!!! Your new partitions are now ready for booting. :laugh::laugh:
Part 2: Modifying Second ROMs' Ramdisk
So 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 recognize 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
First, 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 discussed in 1st post (part2). Then you'll have boot folder in /data/local/tmp. After that do as following:
Code:
cd /data/local/tmp/boot
mkdir ramdisk
cd ramdisk
gunzip < ../initrd.gz | cpio -i -d
this'll extract ramdisk(initrd.gz) in the ramdisk folder inside boot folder. copy this ramdisk folder in your desktop. Inside there are many files. We only need to modify some of them. Ok, change these files in the following area:
For JB Ramdisk​
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
fstab.st-ericsson
# 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
Click to expand...
Click to collapse
recovery.fstab
# 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
Click to expand...
Click to collapse
init.st-ericsson.rc
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
Click to expand...
Click to collapse
For ICS Ramdisk​
fstab (if doesn't exist, ignore it)
# 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
Click to expand...
Click to collapse
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
recovery.fstab
# 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
Click to expand...
Click to collapse
init.st-ericsson.rc (red lines are modified & blue lines are new)
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
Click to expand...
Click to collapse
That's it. You're done editing. Now save & copy these modified files to your /data/local/tmp/boot/ramdisk folder. Then in cmd do as the following:
Code:
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 .
Part 3: Finishing Touch
We're at the end of this long road. You 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 !!!!!!! :good::good:
Hope it is clear to all of you. I tried my best to explain everything. If you need help, feel free to post. Also if you like my guide, give it a 5 star and press thanks to appreciate my work
================== THE END ==================​
F.A.Q​
1. 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.
2. How can I remove the second ROM ?
Ans: Make sure you are in primary ROM, then just delete the 3 partitions from sdcard.
3. 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.
4. Getting status 7 error ?
Ans: Delete assert function from updater-script.
5. 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.
6.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.
7.Getting "somthing went wrong. please see log!" in bootmenu ?
Ans: You have done something wrong in settings.ini or folder naming. Check again.
Very good tut. Men !
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
JohnLouise said:
Very good tut. Men !
Click to expand...
Click to collapse
thnx
mohammadagha said:
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
Click to expand...
Click to collapse
Yes we'll need them for second ROM. I'll upload guides for them soon
If it belongs to dev section, pls can someone tell the moderator to move it ?
Nice
You are the best :good::laugh:
Good start!
very nice tutorial
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
NoobCoder said:
I'll upload soon guides for booting into second ROM. Pls be patient
Click to expand...
Click to collapse
Thanks for this bro.... waiting for other part..... :cheers:
Anthrax said:
Thanks for this bro.... waiting for other part..... :cheers:
Click to expand...
Click to collapse
cmdline in setting.ini belongs to Xperia U, You can find it for sola, Just open kernel.elf for sola with notepad, You can find it at the end of notes.
mohammadagha said:
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
Click to expand...
Click to collapse
By DDMS . Also I reported this thread to move into the dev section, but moderator said this is the right section. Anyway to all users, please report this thread to make it sticky/pinned so that no one have any problems finding it
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
can u post same for Xperia P
dd98 said:
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
Click to expand...
Click to collapse
No, boot.img can't be extracted with winrar. you copied the boot.img to /data/local/tmp, right ? Please provide a screenshot if this doesn't help you.
Aamirx12 said:
can u post same for Xperia P
Click to expand...
Click to collapse
Sorry bro, munjeni stopped P's development. So I can't do it
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
cpkunki said:
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
Click to expand...
Click to collapse
Guess we're the lucky ones . Also there were many user who tried to test. That encouraged munjeni bro to keep the thread updated.
I'll check files uploaded by munjeni to get an idea how to do it in sola. But I think he mentioned it in post 4 in sola section. Check that and follow this guide. I'm sure you'll be able to do it
Can't umount
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
cesanaboia said:
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
Click to expand...
Click to collapse
That's strange. It didn't occur to me. You have 1.2GB free after creating all partition or before? If before, then you have to free more space. If it doesn't help, pls post a screenshot. Also don't create partitions yet. I'll update the post with new code.
Sent from my Xperia U using Tapatalk 2

CMxx [sdcard as Emulated] {Walkthrough} Guide

Hello,
This guide will help you merge userdata and media partitions in to one Big for 16gb Nooks is aprox. 14,3GB and for 8Gb is aprox 6.1GB
What are those?
userdata is your /data partition and in that one you can currently install the apps/games until is full.
Media is your internal sdcard(emmc)
What we are going to do?
We will delete both userdata and media and make a bigger userdata and inside that we are going to mount the media partition so will become like this /data/media.
Required
1.Working CyanoBoot aka 2ndary bootloader.
2.Fastboot drivers and adb shell drivers with both of them functional
3.A special recovery to perform the merge.
4. A little patience until is implemented into cm as a special recovery will be needed after this merge.
You cant use any existing recoveries after this is done.I or chrmhoffmann will post a special recovery after the changes are done on device tree.
A special thanks to meghd00t for the sgdisk tool. A very valuable tool for this task.
So how this is done already!
1. Download the special recovery from here
http://goo.im/devs/demetris/Acclaim/CM11//sgdisk-recovery.img
Mirror
http://s000.tinyupload.com/index.php?file_id=57668299249558322082
2. Download the new cm recovery from here
https://goo.im/devs/chrmhoffmann/cm-12.0/acclaim/recovery-L-acclaim-20150221-ENG.img/
Mirror
http://s000.tinyupload.com/index.php?file_id=07462035216933296298
3.Put both into your working fastboot folder.
4.Enter fastboot mode with holding N and select fastboot on Cyanoboot menu.
5. Copy&Paste the next lines
Code:
fastboot flash recovery sgdisk-recovery.img
fastboot reboot
6.Enter recovery with holding N and select Internal eMMC Recovery from Cyanoboot menu.
7. Copy&Paste the next lines
Code:
adb shell
You get a # and you are now in adb shell interface and you are root so, lets delete both partitions with:
Code:
sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -d 11 -d 10
And merge into one
Code:
sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -n 0:0:0
Name the new partition into userdata
Code:
sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -c 10:userdata
Format our new partition into EXT4
Code:
make_ext4fs -L userdata /dev/block/mmcblk0p10
Check if all done ok
Code:
parted /dev/block/mmcblk0
Code:
print
It should print in the end (for 16GB nooks)
10 1611MB 15.9GB 14.3GB ext4 userdata
It should print in the end (for 8GB nooks)
10 1611MB 7734MB 61240MB ext4 userdata
Number 10 is your new partition, 14.3GB/6.1GB is the partition size ext4 is the filesystem and userdata is the name of the partition
After that you can issue a
reboot
Enter fastboot again and flash the new recovery [recovery-L-acclaim-20150221-ENG.img]
For F2FS support boot into new recovery
Code:
adb shell
Code:
#mkfs.f2fs /dev/block/platform/omap/omap_hsmmc.1/by-name/userdata
This guide is for an alternate way of #1 post guide using a big part of it throughout.
1.Download new recovery from #1
2.Flash it with fastboot
3.Boot in it
4.Download this
http://s000.tinyupload.com/index.php?file_id=14937290426749868964
unzip it and push it to /tmp with adb
Code:
adb push sgdisk /tmp/
Code:
adb shell
Code:
chmod +x /tmp/sgdisk
Code:
umount /storage/sdcard1/
Code:
/tmp/sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -d 11 -d 10
Code:
/tmp/sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -n 0:0:0
Code:
/tmp/sgdisk /dev/block/platform/mmci-omap-hs.1/mmcblk0 -c 10:userdata
Now depending what filesystem you want you must use the right command
EXT4 Use:
Code:
mkfs.ext4 /dev/block/platform/omap/omap_hsmmc.1/by-name/userdata
F2FS Use:
Code:
mkfs.f2fs /dev/block/platform/omap/omap_hsmmc.1/by-name/userdata
Thats it.
really
Dont do this yet. CM11 does not support this at the moment.
Chris
Sent from my TF300T using xda app-developers app
Sorry if I sound like a noob, but, why exactly is it so difficult to change internal SD to external in CM11 specifically for the Nook Tablet? I have switched up the external SD as my internal SD on my Samsung GS2 running CM11 HellKat ROM quite easily. But then again, CM11 HellKat has a functioning vold.fstab, but the Nook Tablet does not. Why is that? Just curious.
sagirfahmid3 said:
Sorry if I sound like a noob, but, why exactly is it so difficult to change internal SD to external in CM11 specifically for the Nook Tablet? I have switched up the external SD as my internal SD on my Samsung GS2 running CM11 HellKat ROM quite easily. But then again, CM11 HellKat has a functioning vold.fstab, but the Nook Tablet does not. Why is that? Just curious.
Click to expand...
Click to collapse
+1 on this.
The current partitoning scheme is a real hinderance. a HUGE hinderance.
are there any clear instructions anywhere to fuse sdcard to /data/media anywhere?
This would really take the Nook Tablet to a whole new level if both partitions could be merged into a single partition as described above. Are you still planning on creating a special recovery for this?
Thanks for all of your hard work on this and Bexus.
So, this merge died?
rpadula said:
So, this merge died?
Click to expand...
Click to collapse
If this is dead is there still an effort to make the media partition (internal storage) act as the SD card? Some apps (like minion rush for example) won't completely install without and external SD card. Used to be able to swap internal and external but can't find a way to do that anymore. Even then there were still issues like the media process frequently crashing. It would be nice to utilize all of the 16GB of the NT and not be required to also use an external SD card. That would be sublime.
Yeah I agree with you guys but cm maintainer don't so if we merge partitions then you won't be able to use official cm
ok guys this guide is adjusted for the new cm12 sdcard as emulated merge with f2fs filesystem support.
Enjoy
I previously resized emmc to ~9.5 GB ( and reduced data). I assume this method should work fine regardless of the relative sizes of these two partitions?
rete said:
I previously resized emmc to ~9.5 GB ( and reduced data). I assume this method should work fine regardless of the relative sizes of these two partitions?
Click to expand...
Click to collapse
Doesnt matter what repartitioning sheme you have as both partitions get deleted then merged so all will end up with the same size.
When i refer to all i mean users that repartioned and those who didnt.
I now added a new alternate guide on #2
Regards
Thanks. This is nice guide for cm12 with nightlies of 22 Feb 2015 and newer.
Chris
If emulated sdcard has been implemented, is it no longer ok to flash back to CM11? I'm sure F2FS is not supported, but is emulated sdcard also not ok?
Also, if we need to get back to stock after this repartition method, will AdamOutler's unbrick method restore the original partitions back?
If you dont merge the partitions there is no problem to go back to any rom cm or stock

filesystem mounting / repartitioning on live android system

Hy!
I have a mi2s and this phone is come to separated partitions in its internal drive. It has separated data and sdcard partition. My sdcard partition not mounted for some reason.
I want to keep this partition system, I just want to either mount the sdcard partition, or resize them without loseing data. (I can delete the sdcard partition but I want the data partition untouched, I had a long fight till this rom started to work with google play store, and I dont really want to remach it after all my apps are installed... Fun thing that after the first boot both partitions were mounted, after my first reboot only the data.)
I tried:
adb mount - adb sees it Android not sees it
write it to the fstab.qalcom - its on the / if I reboot the phone its loaded from somewhere again (I know its a ramdisk), my modifications are not permanent on there
I have basic linux knowlage and I started to dig into it, but I cant google out a general solution.
My questions:
How can I mount a fs like the usb otg from adb/android shell?
Can I edit the fstab file in its permanent store on an installed rooted device? And if I can where?
If I place new lines to the fstab on rootfs how can I tell the system to "reload" it?
Can I extend an ext4 partition from adb without loseing its data? *
* I have the required tools like parted from xiaomi forum, I cant post the link but you can google it with "Mi2S extending size of storage partition stillka".
Any help appreciated, and sorry for my english I'm not native.
So the basics:
If you can mount it from adb its a half win!
Try search the correct block partition and mount it with -t, add the correct file system and don't try auto it.
After you can mount it, you need to start an sdcard process its in /system/bin/sdcard. I had to see the custom rom implementation for that, in cm u need to param it "sdcard from to 1023 1023", but in samsung devices the to is hardcoded, and you nedd to do some sed magic.
After that your android programs will see it as a valid sdcard partition.
The harder way:
Wrap it to a startup script.
Add this script somewhere to run at bootup.
I'm still working on it, but I'm closer and closer. After I have the final solution I will write here once more.
I get so much help from there:
http://forum.xda-developers.com/showthread.php?t=2467048
If somebody want to do this:
After few hours of trying to mount the filessystem in boottime (in CM 12.1 its a hard work), i gave up, and went to a repartitioning way.
BE CAREFUL YOU CAN BRICK YOUR DEVICE IF YOU HAVE NO IDEA WHAT IM TALKING ABOUT!
I merged 2 tutorials:
reboot phone into CWM, connect phone to PC
connect to phone over adb and check if you are root
mount system
umount cache
umount data
copy content of partition_tools.zip into /system/bin and add executable attributes if necessary
Run parted on your device: parted /dev/sdX
Change display unit to sectors: unit s
Print current partition table and note the start sector for your partition: p
Delete your partition (won't delete the data or filesystem): rm <number>
Delete your partition (the second one we will delete data from there): rm <number>
Recreate the partition with the starting sector from above: mkpart primary <start> <end>
Recreate partition 27 (the last) mkpartfs primary ext2 3070 15758
name 26 userdata #we have to set back partition labels
name 27 storage
Exit parted: quit
Check the filesystem of 26: sudo e2fsck -f /dev/sdXX
Resize filesystem 26: sudo resize2fs /dev/sdXX
restore partition 27 with:
tune2fs -j /dev/block/mmcblk0p27
e2fsck -fDp /dev/block/mmcblk0p27
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p27
e2fsck -fDp /dev/block/mmcblk0p27
Of course in parted print you can see your original partition layout and this case it is possible that you have other partition numbers (my 26 partition is labeld by userdata and 27 with storage, and I gave more space to userdata from storage without loseing any data from userdata).
You can download the partition_tools.zip from the original miui forum, try to search to mi2s extending size of storage partition. (yes it will work with other devices too)

Mounting F2FS SDCard

Hi, i formatted my sdcard to f2fs and it can be mounted on custom rom i previously use, PixelExtended by changing <type> from vfat to auto in fstab.qcom. Yesterday, i moved to AOSP Kraken and did the same modification to fstab.qcom but sdcard still can't be mounted (unsupported). Is there anything i can do to make my current rom able to mount f2fs sdcard? Maybe like replacing the files or anything using the files from previous rom that is responsible to mounting sdcard?
NB : My device is Redmi Note 9 Pro (joyeuse). Im using same custom kernel in both rom
I have same problem here
Spicy_WinG said:
Hi, i formatted my sdcard to f2fs and it can be mounted on custom rom i previously use, PixelExtended by changing <type> from vfat to auto in fstab.qcom. Yesterday, i moved to AOSP Kraken and did the same modification to fstab.qcom but sdcard still can't be mounted (unsupported). Is there anything i can do to make my current rom able to mount f2fs sdcard? Maybe like replacing the files or anything using the files from previous rom that is responsible to mounting sdcard?
NB : My device is Redmi Note 9 Pro (joyeuse). Im using same custom kernel in both rom
Click to expand...
Click to collapse
@namhoang235
Its possible to mount f2fs/ext4 microSD / usb-otg on android.
i use f2fs since 2017 for microSD on Android.
u need to be rooted, and, a your need to have kernel f2fs-support.
if you can format /data as f2fs and mount it.
then, youtl already have f2fs support.
else you can use any custom kernel with f2fs support.
as (on 2018) for my asus x00td device, i requested @Sakhtlonda69 to add f2fs support in his custom kernel build.
(and, he did it!)
----
these are few values , which u need to know, to execute the below commands
# YOUR_DEVICE_NUMBER = the exact partition which is your memory card's 1st partition.
# If you have a device with UFS storage (not eMMC), then, microSD will be most likely at "mmcblk0p1"
# If you have a device with eMMC Storage (not UFS), then, microSD will be most likely at "mmcblk1p1"
# If you still can't understand what I'm saying,
# Make sure your memory card is inserted,
# then,
# just go to /dev/block from any rooted file manager
# search "mmcblk1" there.
# if it only shows these 2 files: mmcblk1 and mmcblk1p1
# then, "YOUR_DEVICE_NUMBER" is "mmcblk1p1"
but, if you can't find anything with "mmcblk1"
#then, search "mmcblk0" there.
# if it only shows these 2 files: mmcblk0 and mmcblk0p1
# then, "YOUR_DEVICE_NUMBER" is "mmcblk0p1"
so, "YOUR_DEVICE_NUMBER" is actually either "mmcblk0p1" or "mmcblk1p1"
WARNING: (If you format any wrong system's internal storages partition, your device will most likely be bricked!)
Understand?
---
#---Format your microSD part with f2fs---#
simply unmount the memory card from Settings > Storage.
then, launch Terminal Emulator/ Termux App
(make sure you have root)
enter below 2 commands one by one:
su
make_f2fs -f /dev/block/YOUR_DEVICE_NUMBER
#---Formated successfully---#
-----
Now reboot your device
After reboot your device show a notification that your Memory Card is corrupted!
(because most of the android system can't mount anything except fat/exFAT for Memory Card - it's normal)
---
to mount the microSD (Memory Card),
Launch Terminal/Termux: and, enter below lines one by one:
(YOU NEED TO ENTER THESE LINES EVERY TIME AFTER YOU REBOOT YOUR DEVICE)
su
mkdir -p /mnt/extsd
mkdir -p /sdcard/_MemoryCard_
# Mount f2fs-microSD at /mnt/extsd
mount -t f2fs -o rw,nosuid,nodev,noatime,noexec,discard,fsync_mode=nobarrier /dev/block/platform/soc/*.sdhci/mmcblk*p1 /mnt/extsd
# Bind using sdcardfs f2fs-microSD from /mnt/extsd to /sdcard/_MemoryCard_
mount -t sdcardfs -o rw,nosuid,nodev,noatime,noexec,fsuid=1023,fsgid=1023,gid=9997,mask=2 /mnt/microSD /mnt/runtime/default/emulated/0/_MemoryCard_
----
Now,
microSD is mounted under Internal Storage's _MemoryCard_ folder.
---------
(Extra things)
If you dont want to show Memory Card Corrupted (annoying) Notification on each boot,
simply edit your /vendor/etc/fstab* file.
(it will be under : /vendor/etc/fstab.qcom or /vendor/etc/fstab.default or /vendor/etc/fstab.emmc)
(if you have more that one fstab, edit all)
Edit fstab* :
Find the line contains
"/devices/platform/soc/ ......... /mmc_host*"
add a "#" at the starting of that line (without quotation marks)
and save that file.
Reboot your device.
Now, It won't show any corruption device notification.

Categories

Resources