[MOD] Data2SD (Enhanced) - I/O Fix

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
0
At the suggestion of several users, I am forking the previous thread. I am planning on supporting several ROMs and this is the best course to keep everything organized and provide support.

What is this?

Background:
The speed of the flash memory in the Transformer line of tablets is very poor. This is very apparent when installing or updating applications from the Play Store, copying files over USB, or using an app that caches lots of data like a web browser. The tablet will hiccup and stutter due to the I/O bottleneck. Running Androbench shows random write speeds averaging less than .2MB/sec.

The workaround:
Utilizing a fast, class 10 microSD card, we can move the /data partition to something significantly faster. The /data partition is where apps are installed to and where they store their configuration information and data. By redirecting /data to these fast microSD cards, we eliminate this bottleneck from our devices. With a properly fast card, users have reported a complete elimination of I/O related hiccups and system freezes. I have based my enhancements on the initial work by TweakerL on the Transformer Prime. Credit to fordwolden to porting his work to the Infinity.

The enhancements:
Previous implementations of this mod had the internal data partition mounted to /data2, with the media subfolder (your internal user storage) only available via root apps. There were symlinks set up at /sdcardi, etc, but these still required root permission to access. This is due to permissions on the /data partition and applies to both /data and /data2. Google gets around this by creating a "virtual" sdcard that points to /data/media. I have created a second "virtual" sdcard that points to /data2/media. This mod creates the scenario below:

/data = ext4 partition on microSD (fast)
/data2 = ext4 partition on internal storage (slow)

New changes:

/data/media -> Virtual SD Card Daemon -> /storage/sdcard0
/data2/media -> Virtual SD Card Daemon -> /storage/sdcardi
/sdcardi -> Symlink -> /storage/sdcardi
/mnt/sdcardi -> Symlink -> /storage/sdcardi

/storage/sdcardi is the virtual SD card for the internal storage. You should see all the files you had saved to this space before using data2sd. These files should be accessibly by any standard non-root Android app.

Note to kernel developers: This mod is more than just changes to the kernel. In order for the internal storage to be properly mounted at /storage/sdcardi, I have modded the Virtual SD Card Daemon that comes with Android. The stock binary is /system/bin/sdcard. I made a copy, modified it using a hex editor, called it /system/bin/sdcardi, and included it in my flashable zips. If you wish to make a data2sd version of your kernel, you must include this file in your zip. Additionally, be sure to add the "service sdcardi" line to your init.cardhu.rc that I have in mine.

Installation

Requirements

1) Class 10 microSD, at least 8gb
2) A computer with card reader
3) Partitioning software. Recommended: gparted LiveCD

Instructions

1) Decide how big you want to make the ext4 partition for /data. Remember, this is going to be the space for installing applications AND the /sdcard space that games will use the cache their extra data. Kindle books, Dropbox files, pics from the camera WILL ALL GO HERE. Personally, I decided to make the ext4 partition the whole 64gb of my card.

The ext4 partition has to be partition #2 on the microSD card. Why? This is to give people with large cards the option of creating a FAT32 or NTFS area as partition #1. This allows the card to be read by a Windows or Mac computer using a card reader. I use my tablet as my card reader with the USB cable, so I wasn't worried about this. I used gparted to create a small 8mb unformatted partition as partition #1, then a second 64gb partition to fill the rest of the card. I formatted this second partition in ext4.

2) Format your microSD card - Download Gparted Live CD (http://goo.gl/dJQAu) and use Imgburn (http://goo.gl/33MY9) to write to disc. Boot to Gparted using your CD after setting the CD as the primary boot device in your BIOS. Once in Gparted, create the 2 partitions described above, the first partition is Fat32, the second partition is ext4 or ext2. Set both partitions to type: Primary.

3) Insert microSD into tablet and flash any data2sd kernel for your ROM. (Note: Flashing any ROM will overwrite your data2sd kernel. You will have to re-flash the data2sd kernel if you change ROM or even upgrade your current one) After booting back into Android, you should be greeted with the Setup Wizard. Remember, this is a fresh /data partition, so it's a clean slate. It's a good idea to take a TitaniumBackup** ahead of time. I am experimenting with ways to make the transition more painless.

**Note about taking a TitaniumBackup before switching to data2sd. After the conversion, your internal storage will be mounted to /sdcardi. By default, TitaniumBackup looks for previous backups in /sdcard not in /sdcardi. You have two choices. Copy the TitaniumBackup folder from /sdcardi to /sdcard and restart the app, or change the backup location to /sdcardi/TitaniumBackup in the app preferences. Either of these options should work fine.

Optional: Verify data2sd is working. Pick any method you like:
a) Open a file explorer such as Root Explorer, ES, etc. You should see /sdcard and /sdcardi and be able to browse the files within. /sdcard is your ext4 partion on the microSD while /sdcardi is the internal storage. You should able to copy data between them.
b) Download "Androbench" app from the market and run "micro" sdcard check, if you see 0.4mb/sec or more in random write you're on data2sd.
c) Power off your device, remove your microSD card, then power back on your device. You should received an error message "Encryption unsuccessful". Insert microSD and reboot to fix.

Uninstallation

Don't like data2sd? Just flash a non-data2sd kernel using recovery and when you boot back into Android your /data will be on the internal storage. This could also be accomplished by flashing your ROM on top of itself without wiping.

Troubleshooting

1) Grab the mount-data2sd.zip from the second post.
2) Boot into TWRP and flash the mount-data2sd.zip. This will mount the microSD as /data in recovery. It will allow us to wipe it, format, etc using recovery.
3) Wipe "Internal Storage". This will erase the entire ext4 partition on your microSD.
4) Flash ROM
5) Flash data2sd kernel for ROM

*CAUTION*: If you don't flash mount-data2sd.zip before your wipe, you will be wiping your internal memory.

Download data2SD kernels

These are flashable zips. It will disable journaling on the microSD ext4 partition. You do not have to do this manually! Flash these after flashing the ROM.

CyanogenMOD 10.1 - beta2: http://d-h.st/rOe (Based on 4-2 nightly and may behave unexpectedly on other builds)
CleanROM 3.2.2: http://d-h.st/sCa - WORKS WITH CleanROM 3.3!
clemsynTFUniversalCyano650GPUFsyncver3: http://d-h.st/duw
ClemsynTFUniversalStock: http://d-h.st/IBm
clemsynTFUniversal650GPUver7 (Stock/CleanROM): http://d-h.st/S4k
 

Attachments

Last edited:

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
0
Recovery

I made a flashable zip to help the recovery console understand our modification. By default, if you go into recovery and do a factory reset, it is formatting the /data partition on the internal storage. The issue same applies to nandroids. We may be using the second partition of our microSD card for /data, but the recovery does not know this. It will look to the internal /data partition during backup and restores.

This zip does not make any modifications to your tablet or copy any files. It simply updates your recovery mount points. The changes are temporary and are lost during the next reboot. You will need to flash it each time you boot into recovery.

After flashing this zip you will be able to:

1) Wipe data / Factory reset. The /data partition on the microSD will be wiped

2) Backup and restore nandroids. The /data partition on the microSD will be backed up or restored.

3) Choose "Flash zip from internal sdcard" and browse the files on the internal storage

4) Access and flash zips from the microSD storage. Choose "Flash zip from internal sdcard" and notice the !microSD folder at the top. This is a symlink that will kick you over to the microSD storage. This !microSD folder appears on your internal storage after you flash this zip for the first time. It remains unless you delete it. Even so, next time you enter recovery this !microSD symlink will not go anywhere until you flash this zip.

Please report your experience with this.

http://d-h.st/pPe
 
Last edited:

Diogenes5

Senior Member
May 2, 2012
309
111
0
Houston, TX
So this is basically flashable on CleanRom 2.3 right? Only thing wrong is that it doesn't show up in windows over USB? I can live with that as long as apps can read it in the Android OS itself.
 

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
0
So this is basically flashable on CleanRom 2.3 right? Only thing wrong is that it doesn't show up in windows over USB? I can live with that as long as apps can read it in the Android OS itself.
Nope. This has changes to framework-res.apk which is ROM specific. I will post a CleanROM 2.3 version in a few minutes for you guys. :)
 
  • Like
Reactions: stanglifemike

clownberg

Senior Member
Jun 3, 2010
101
5
0
Thanks - Appreciate your hard work

---------- Post added at 08:46 PM ---------- Previous post was at 08:37 PM ----------

wow that was fast-thanks

---------- Post added at 08:58 PM ---------- Previous post was at 08:46 PM ----------

i was getting 6000 with clemsyn -I got low 5000's with this new mod
 
  • Like
Reactions: sloanster

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
0
Unable to have it work with cleanrom. Boot loop :confused:
Use recovery to wipe the /cache partition. Due to the changes in framework-res.apk this may be necessary if you aren't coming from a completely clean install of a ROM.

I just booted to recovery and wiped my microSD /data partition. I also wiped /cache and /system. I installed CleanROM 2.3 and in the same recovery session I flashed the clemsynTF700ver22GPU650VC-data2sd kernel and it booted right up.
 
Last edited:

denpri

Member
Nov 10, 2007
19
5
0
May be a stupid question but do you still need TWO primary partitions on the SD card (i.e., first is FAT32 while second is Ext4 and used by the mod)? If this isn't necessary or not possible, should the recovery (i.e., installation) files be placed in internal storage?

Forgot to mention I'm using Windows 7 MTP and CleanROM 2.3
 
Last edited:
T

titou00075

Guest
Use recovery to wipe the /cache partition. Due to the changes in framework-res.apk this may be necessary if you aren't coming from a completely clean install of a ROM.

I just booted to recovery and wiped my microSD /data partition. I also wiped /cache and /system. I installed CleanROM 2.3 and in the same recovery session I flashed the clemsynTF700ver22GPU650VC-data2sd kernel and it booted right up.
Ok thanks. Will do:thumbup:
 

tyfoxx

Senior Member
Mar 4, 2006
574
43
0
Toronto
cheers

Thanks Gonna try this.

done the work install all three files in the OP, however it is taking a long time to boot....Can someone give me an idea as to how long this normally take onn first bootup after a fresh install?

please advise
tyfoxx
 
Last edited:

jaxboater

Senior Member
Dec 15, 2007
265
21
0
Fl.
Sweet

I just ran every shortcut I could think of:
I used Mini partition tool to reduce reduce my 32 gig fat down to 16 gigs & then created a 16 gig ext4 partition.
Wiped everything in twrp and re flashed Clean 2.3 then the new zip.

All I can say is WOW.
 

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
0
Restored everything. Works great no more stalls and stable so far. Hope it stays this way. Now to focus on battery life.

Sent from my HTC Ruby using xda app-developers app
Glad it's working! I've prepared a little treat for everyone to make our recovery lives a little easier. Need to test a few more things before I post!
 

JekyllInside

Senior Member
Apr 10, 2012
108
29
48
I'm running CleanROM 2.3 and ClemsynTF700ver22GPU650VC (awesome combo, btw). If I want to use this MOD, should I need to flash first CleanROM-2.3-data2sd.zip and later ClemsynTF700ver22GPU650VC-data2sd.zip, right? Of course, also, formating my microSD using ext4.
 

stanglifemike

Senior Member
Apr 21, 2008
3,140
491
0
outside of ATL, GA
Awesome work here Mistar!!!! Thank you so very much for this!!! Gonna replace my SanDisk 32gb Class 4 card with a SanDisk 64gb Class 10 before I run this on CleanRom. I'm super excited about this mod!!!!!! Thanks a million!!!!!!

Sent from my EVO 4G LTE using xda premium