[ROM][4.0.4][STABLE][MOD] CM9 with /data on the external SD (avoid EU bug)

azunino

Senior Member
Feb 26, 2012
337
218
73
*** This MOD only works with phones with working internal SD ***

*** DO NOT FLASH THIS IF YOU ARE AFRAID OF EXPERIENCING BOOTLOOPS ***


To those of you who have not been following the Encryption Unsuccessful thread: http://forum.xda-developers.com/showthread.php?t=1447303, Several weeks ago I proposed a workaround to reduce the possibility of crippling our phones with the infamous EU bug of ICS: http://forum.xda-developers.com/showpost.php?p=26593304&postcount=632

In short, the idea is to force ICS to use /data on the external micro SD instead of the internal. In this way I hope the EU bug will corrupt the external SD (fixable by reformatting it using a card reader on a PC) instead of the internal. In addition, we may be able to reproduce the EU bug and obtain some nice logcats for helping our great devs at finding and hopefully fixing the bug. Besides, I'd rather break a 10USD micro SD card than a 300USD captivate.

The idea is simple so is the "solution". I've developed some scripts that take as input any ICS ROM (tested with CM9, AOKP and MIUIv4) and modify it to use /data on the external SD. I've installed my modified CM9 running with /data on a partitioned 8GB SanDisk class 4 SD card with good performance. BTW, a faster SD does not imply faster performance in this setup, because the way Android uses /data: http://forum.xda-developers.com/showthread.php?t=1005633

Considering that the modified ICS does not mount /data on the internal SD and mounts the external SD FAT partition as /sdcard, it does not even require the internal 16GB FAT partition... in theory it is less likely that the EU bug will kill the internal SD, but no one knows for a fact. Moreover, the internal SD card FAT partition gets mounted as /emmc, but you can unmount it from Settings>Storage just to be on the safe side.

I've been using the modified CM9 for some time and it works great. Some testers have also helped. Off course YMMV. Please do not report bugs to the developers of CM9 (AOKP or MIUI) if you use this mod because this is not official.

Read carefully before proceeding:

*** Disclaimer: Usual disclaimer applies here as well... you use this at your own risk, I am not responsible for anything that happens to any of your devices. You assume all responsibility when using this ROM. ***

To install this you need a micro SD card with enough space for two partitions (1GB for /data + all the space you need for music, photos, videos, games, etc. on /sdcard)

First, partition a micro SD card using a PC. Create two primary partitions (not logical) in this exact order:
  1. a FAT32 partition that will be mounted as /sdcard: the SD card capacity - 1GB (or more if you have many apps)
  2. an EXT4 partition that will be mounted as /data: 1GB (or more if you have many apps)

There are many programs to partition SD cards. I have used the Disk Utility included with Ubuntu 12.04. I don't have Windows, but some people reported that this may help: http://forum.xda-developers.com/wiki/SD_card_partitioning

Optional Insert the partitioned SD card in your phone and boot whatever Android you have to check if it works. On CM7 the external FAT32 partition should be mounted as /emmc and the EXT4 as /sd-ext

*** Disclaimer: I've flashed the modified CM9 from CM7.2, CM9 and MIUIv4, so I have no idea if other combinations will work ***


Now follow these steps:
1) Ensure you are on GB Bootloaders and you have a recent CWM recovery (tested with CM7)
2) Verify that the 3 button combo works for booting in CWM. Otherwise STOP here and read more about flashing ROMs.
3) Download the modified ICS: CM9.1 or AOKP b40
4) Download Gapps for ICS: http://goo.im/gapps/
5) Copy the two files to the FAT partition of the partitioned micro SD card using your PC and insert it into your phone.
6) Boot your phone to CWM
7) Wipe data/factory reset, wipe cache, wipe dalvik cache under advanced
8) Flash Rom (install zip from sdcard->choose zip from internal card), it will bootloop because of the new mount points.
9) Remove the battery and reboot into recovery using the 3 button combo
10) Flash Rom again. Note that now the internal SD and external SD are reversed. (install zip from sdcard->choose zip from SD card)
11) Flash Gapps: http://goo.im/gapps/
12) After some minutes (2 to 5) ICS will be ready


This is the output of the mount command after booting:




*** Please DO NOT report bugs to the developers of CM9, AOKP, Devil or Semaphore kernels if you use this mod because this is not official. ***

All credits to:
- the CyanogenMod team
- the AOKP team
- DerTeufel1980 (for the Devil kernel and his detailed instructions about how to modify the kernel)
- stratosk (for the Semaphore kernel and his instructions about how to compile the kernel)
- all the people who have tested this mod



---
Changelog:

8/29/2012:
CM9.1

8/11/2021:
CM9 stable!!!!

7/19/2012:
CM9 RC2. I will update only when RC/stable versions are released.

7/18/2012:
Kernels removed.

7/17/2012:
Updated Semaphore Kernel (1.2.6)

7/16/2012:
Updated Devil Kernel (1.0.0-rc3)

7/11/2012:
Updated Devil Kernel (0.98.3)

7/3/2012:
Added link to the most recent CM9 nightly (automatically patched and uploaded)

7/1/2012:
Updated Devil Kernel (0.92)
Updated CM9

6/29/2012:
Added Semaphore Kernel. Thanks stratosk!
Added AOKP b40
Updated CM9

6/20/2012:
Added Devil3 Kernel. Thanks DerTeufel1980!

6/19/2012:
Updated CM9

6/16/2012:
New script for modifying any CM9 ROM. Updates are easy!

6/14/2012:
Initial release based on a recompiled CM9

--
IF I HAVE HELPED YOU IN ANY WAY, PLEASE THANK ME or DONATE: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AQF82UCZ9AF6L
 
Last edited:

visionlogic

Senior Member
Dec 29, 2008
138
45
0
Dixie
... In theory it is possible to extract from a boot.img file the init.rc file with the mappings and modify it, but I have not idea how (some help please reversing https://github.com/CyanogenMod/android_device_samsung_aries-common/blob/gingerbread/mkshbootimg.py ?). Well, if we can solve that, I can write a shell script to convert any(?) ICS based ROM/kernel and modify it to use /data on the external SD.
Perhaps this would be of some help?:

HOWTO: Unpack, Edit, and Re-Pack Boot Images
 
  • Like
Reactions: azunino

Fishmanzero

Senior Member
Sep 20, 2010
133
25
0
I saw "Other kernel will not work" so it seems that you have compiled a modified kernel to change the mount points ? If so I think it's also very promising to be a solution to build a CM to use with broken internal storage...
I'm using stock-based roms with modified kernels but I couldn't manage to repack a working CM compatible kernel...
 

azunino

Senior Member
Feb 26, 2012
337
218
73
I saw "Other kernel will not work" so it seems that you have compiled a modified kernel to change the mount points ? If so I think it's also very promising to be a solution to build a CM to use with broken internal storage...
I'm using stock-based roms with modified kernels but I couldn't manage to repack a working CM compatible kernel...
That is correct. I modified the files that contain the mount points and the updater.sh. The problem with these files is that they are packed together in a ramdisk (ext2 filesystem image), recovery and with the kernel in a boot.img file. Therefore, it is not trivial to modify them to work with any kernel/ICS ROM.

Yesterday, after hours of reading hexadecimal boot.img files... I wrote a python script to unpack a boot.img file and extract from it the kernel, ramdisk and recovery ramdisk. These ramdisks are easy to modify (cpio format), so right now I'm testing a shell script that takes as input any ICS based ROM (or kernel) and modifies it to use /data as my modded CM9. In other words, things are getting interesting ;-)

Once I finish the script It would be very easy to change mount points as you wish because they will be no longer hardwired in each ROM/kernel. So... let your imagination fly.
 

azunino

Senior Member
Feb 26, 2012
337
218
73
Updated OP. Now I can automatically convert CM9 and AOKP to use /data on the external SD.

I'm extending the script to handle kernel updates. BTW, some of them seem to use a different boot.img format.
 
  • Like
Reactions: daskanda

azunino

Senior Member
Feb 26, 2012
337
218
73
I will post the scripts, but first I have to make them more user friendly and add some error handling code


Sent from my SGH-I897 using XDA
 
  • Like
Reactions: daskanda

swayjd

Senior Member
Aug 10, 2011
269
39
0
Dublin
Just to clarify, to those that used this trick in the past (other phones) and got the encryption unsuccessful bug, what happened was, their external sd card got unusable by the phone, but formatting it with a card reader was all it took to bring it back.

I expect that a good look at these corrupt sd cards would bring good insight to solve the problem.

Sent from my SGH-I897 using XDA
 
  • Like
Reactions: azunino