FORUMS
Remove All Ads from XDA

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

288 posts
Thanks Meter: 412
 
By Mistar Muffin, Senior Member on 29th October 2012, 08:13 PM
Post Reply Email Thread
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
Attached Thumbnails
Click image for larger version

Name:	transformer_data2sd_mtp.jpg
Views:	45270
Size:	30.4 KB
ID:	1440999  
The Following 70 Users Say Thank You to Mistar Muffin For This Useful Post: [ View ] Gift Mistar Muffin Ad-Free
 
 
29th October 2012, 08:14 PM |#2  
OP Senior Member
Thanks Meter: 412
 
Donate to Me
More
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
The Following 15 Users Say Thank You to Mistar Muffin For This Useful Post: [ View ] Gift Mistar Muffin Ad-Free
29th October 2012, 08:14 PM |#3  
OP Senior Member
Thanks Meter: 412
 
Donate to Me
More
This one too.
The Following 4 Users Say Thank You to Mistar Muffin For This Useful Post: [ View ] Gift Mistar Muffin Ad-Free
29th October 2012, 08:18 PM |#4  
Diogenes5's Avatar
Senior Member
Flag Houston, TX
Thanks Meter: 111
 
More
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.
29th October 2012, 08:21 PM |#5  
Senior Member
Thanks Meter: 5
 
More
can I use flash this on cleanrom 2.3 to diasable journalling on my ext4 partition
29th October 2012, 08:32 PM |#6  
OP Senior Member
Thanks Meter: 412
 
Donate to Me
More
Quote:
Originally Posted by Diogenes5

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.
The Following User Says Thank You to Mistar Muffin For This Useful Post: [ View ] Gift Mistar Muffin Ad-Free
29th October 2012, 08:58 PM |#7  
Senior Member
Thanks Meter: 5
 
More
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
The Following User Says Thank You to clownberg For This Useful Post: [ View ] Gift clownberg Ad-Free
29th October 2012, 09:13 PM |#8  
OP Senior Member
Thanks Meter: 412
 
Donate to Me
More
Quote:
Originally Posted by clownberg

i was getting 6000 with clemsyn -I got low 5000's with this new mod

This is not clemsyn's kernel, this is the stock CleanROM 2.3 kernel. I will mod clemsyn's latest kernel and post it for you.
The Following User Says Thank You to Mistar Muffin For This Useful Post: [ View ] Gift Mistar Muffin Ad-Free
titou00075
29th October 2012, 09:38 PM |#9  
Guest
Thanks Meter: 0
 
More
Quote:
Originally Posted by Mistar Muffin

This is not clemsyn's kernel, this is the stock CleanROM 2.3 kernel. I will mod clemsyn's latest kernel and post it for you.

Unable to have it work with cleanrom. Boot loop
29th October 2012, 09:48 PM |#10  
OP Senior Member
Thanks Meter: 412
 
Donate to Me
More
Quote:
Originally Posted by titou00075

Unable to have it work with cleanrom. Boot loop

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.
29th October 2012, 10:06 PM |#11  
Junior Member
Thanks Meter: 5
 
More
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
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes