FORUMS

XDA Recap: This Week In Android (May 17 – 23)

Another week, another recap. The Sunday tradition marches on this week with a fresh … more

Huawei To Sell Honor Smartphones Via Indian Retail Outlets

World’s fourth largest smartphone maker Huawei plans to now sell its … more

Sunday Debate: Are Smaller Bezels Better or Worth It?

Bezels have been getting smaller and smaller as the years go by, and while devices … more

LG G4 First Impressions and Unboxing – XDA TV

The latest in LG’s signature line of “G phones” has been released. … more
Post Reply Subscribe to Thread Email Thread

Database [GUIDE] How to mount ext4 formatted MicroSD card on Android 4.2.2 Phone/Tablet.

29th August 2013, 03:06 PM |#1  
OP Junior Member
Flag Jefferson City, MO
Thanks Meter: 8
 
Donate to Me
More
Why?

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.

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:
  1. On a locked device, it is not possible to update init script to run the commands at system bootup.
  2. 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.
  3. 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.

The solution?
Pre-requisites:
Step 1 - Fix adb localhost.
Open terminal and type the commands:

Code:
su
setprop service.adb.tcp.port 5555
adb kill-server
stop adbd
start adbd
HOME=/sdcard adb start-server
adb connect localhost
adb -s localhost:5555 shell
exit
stop adbd
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
start adbd
Step 2 - Install scripts.

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:

Code:
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:

Code:
adb push sd.sh /sdcard/sd.sh
adb push msd1.sh /sdcard/msd1.sh
adb push msd2.sh /sdcard/msd2.sh
adb shell
su
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
exit
exit
Step 3 - Profit.

In terminal app run command:

Code:
sd.sh
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.



Disclaimers

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.
Attached Files
File Type: zip MountExt4SD.zip - [Click for QR Code] (995 Bytes, 3238 views)
Last edited by sashavasko; 3rd September 2013 at 05:07 PM. Reason: Added command to kill adb server to avoid power drainage, added note on umask 077
The Following 4 Users Say Thank You to sashavasko For This Useful Post: [ View ]
 
 
16th March 2014, 01:13 AM |#2  
Junior Member
Thanks Meter: 0
 
More
Motorola Droid 4 (xt894)
Hello!

if you have a Motorola Droid 4 you need to change the third row in "msd2.sh" from
"mount -t ext4 /dev/block/mmcblk1p1 /storage/extSdCard && sleep 5 && /system/bin/vold" to
"mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1 && sleep 5 && /system/bin/vold"

in order to get it to work, thanks for the guide!

Best Regards
/ Rasmus
24th March 2014, 01:07 AM |#3  
SeaFargo's Avatar
Senior Member
Flag Rome
Thanks Meter: 32
 
More
Thumbs up It works well on TW based MIUI
It works well on TW based MIUI, so many many thanks!!!
But I still have the permission problems mentioned.

AOSP based MIUI is ext4 compatibile out of the box, and without permission problems.

This trick is amazing, but the permission issue make it useless ...

I can not shot a picture and than have to manually change the permission of tehf ile in order to view it on the gallery ...

Is there a definititive solution?
15th May 2014, 08:47 AM |#4  
Junior Member
Thanks Meter: 0
 
More
My lg l3 e400..sd card not mounted
to sashavasco:

sir, pls help configuring my phone...the codes u've given at the top part seems to work accordingly..but after when i entered the command
"cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys"
it says: "no such file or directory"
can you point out the problem of the device plss...
i appriciate your response..
my phone s LG L3 E400..CYANOGENMOD 9..external sd wont mount on my device
5th June 2014, 01:22 PM |#5  
kevp75's Avatar
Senior Member
Flag MA
Thanks Meter: 4,322
 
Donate to Me
More
Quote:
Originally Posted by sashavasko

Why?


Step 1 - Fix adb localhost.
Open terminal and type the commands:

Code:
su
setprop service.adb.tcp.port 5555
adb kill-server
stop adbd
start adbd
HOME=/sdcard adb start-server
adb connect localhost
adb -s localhost:5555 shell
exit
stop adbd
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
start adbd

I am getting an error here: adb -s localhost:5555 shell stating device offline. I've done this 6 times now, and it's always the same error

Galaxy S4 i337 NC1 Rooted
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2014-06-05-08-25-53.jpg
Views:	567
Size:	193.2 KB
ID:	2781871  
Last edited by kevp75; 5th June 2014 at 01:28 PM.
11th September 2014, 01:26 PM |#6  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by kevp75

I am getting an error here: adb -s localhost:5555 shell stating device offline. I've done this 6 times now, and it's always the same error

Galaxy S4 i337 NC1 Rooted

the same for me...
1st October 2014, 12:09 AM |#7  
Junior Member
Thanks Meter: 0
 
More
same error "unable to connect to local host:5555"
rooted Asus memo-7 build ME173X_US_user_4.2.404152_20140714 release-keys. But thanks for the heads up on Cyanogenmod.
28th November 2014, 10:04 PM |#8  
Junior Member
Thanks Meter: 1
 
More
>>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.

Re-running vold crashes it ("Segmentation fault") if sdcard is already mounted in ext4. If not, it restarts gracefully.
Stock android 4.4.2. AFAIK, vold must inform userspace stuff that sdcard is available, without it, android do not see any sdcard at all...
What can be done here?

p.s. Is there anywhere patched or recompiled vold which supports ext4?
The Following User Says Thank You to Nothing89 For This Useful Post: [ View ]
21st December 2014, 03:10 PM |#9  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Gigionaytor

the same for me...

same here too. Please help.
19th May 2015, 01:09 PM |#10  
Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by ZeroBubble

same here too. Please help.


Same error!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes