[GUIDE] How to mount ext4 formatted MicroSD card on Android 4.2.2 Phone/Tablet.
MicroSD cards are traditionally formatted using ExFAT filesystem. The trouble is that while universally compatible, ExFAT is rather primitive filesystem prone to data loss, and poor speed. Linux ext4 on the contrary is highly reliable and very fast.
Trouble is that, and I quote, "Android supports devices with external storage, which is defined to be a case-insensitive and permissionless filesystem." (see http://source.android.com/devices/tech/storage/
Well that pretty much narrows it down to dumb stuff like ExFAT.
Note: As of JB (Android 4.1) default umask is 077, which means that files created by apps on the ext4 formatted SD card will only be readable by the same apps, unless you manually update permissions. See this thread for more: http://forum.xda-developers.com/show...=889471&page=5
The good news is that Android has Linux at its core, which naturally supports ext4, and actually all of the internal storage is (or will be in near future) formatted this way. The design limitation mentioned above is somewhat artificial and is enforced by
restricted functionality of funky little daemon, called vold. The sole purpose of vold is not monitor external storage,
detect filesystem on it, mount it as specified in /etc/vold.fstab (or vold.xxx in Android 4.3), and then report to the Volume Manager.Volume Manager in turn notifies the MTP application, and all other apps, displays icons and handles rest of user-visible stuff.
Stock Android vold only supports ExFAT/vfat filesystem. It has been improved in Cyanogenmod to support ext4 and NTFS filesystems, but for those of us stuck with OEM Android this goodness in unavailable. In my experience simply re-building vold from CM as part of AOSP,
while yields an executable, this executable results in a boot loop for an unclear reason.
All hope lost seemingly, yet there is a silver lining.
If MicroSD card is mounted manually in the way that vold can see it, re-running vold will properly report it to the Volume Manager and it will be recognized and utilized by apps.
In theory this is easy to accomplish on any rooted device, in practice there are a number of obstacles:
- On a locked device, it is not possible to update init script to run the commands at system bootup.
- Since Android 4.2, mount propagation no longer work (as described here http://forum.xda-developers.com/show...php?p=36889027),
so if sdcard is mounted in terminal, vold will still not see it. Hence the mount operation has to be done in adb.
- Furthermore in Android 4.2.2, running adb on localhost is broken as a result of it loosing its private key.
See here https://code.google.com/p/android/is...etail?id=48126 for more.
Step 1 - Fix adb localhost.
Open terminal and type the commands:
Step 2 - Install scripts.
setprop service.adb.tcp.port 5555
HOME=/sdcard adb start-server
adb connect localhost
adb -s localhost:5555 shell
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
Please note that the script msd2.sh has to be modified if your device uses different partition names.
To get list of partition names available run command:
adb shell cat /proc/partitions
There are 3 (very simple) scripts:
sd.sh is just a convenience so that you don't have to type su everytime.
It calls msd1.sh which takes care of starting localhost adb in a reliable way.
It then executes msd2.sh in adb shell, which actually does the mounting trickery.
To install scripts, download the zip file below, open terminal, unzip the archive and change into msd directory.
Then connect your phone to your PC and run the following commands:
Step 3 - Profit.
adb push sd.sh /sdcard/sd.sh
adb push msd1.sh /sdcard/msd1.sh
adb push msd2.sh /sdcard/msd2.sh
mount -o rw,remount /system
cp sd.sh /system/xbin/
cp msd1.sh /system/xbin/
cp msd2.sh /system/xbin/
chmod 755 /system/xbin/*.sh
mount -o ro,remount /system
In terminal app run command:
There will be some messages in notifications bar and then you will be asked if it is ok to restart MTP application. Click Ok.
That should be it.
Note that this last command will have to be executed every time device reboots (see obstacle #1).
You can automate it using Script Manager app from marketplace. In this case, ask Script Manager to run msd1.sh instead, marking it as Root script.
I've developed and tested this procedure on Samsung Galaxy S4 Active phone from ATT.
Should work for any other Android 4.2 device.
The steps outlined are non-destructive if done properly and should not affect any other functionality, yet obviously I do not assume any responsibility for you damaging your device in the process.
It is a good idea to read the linked articles before performing the procedure, to get a better understanding of what is actually going on.