5,594,518 Members 32,587 Now Online
XDA Developers Android and Mobile Development Forum

[MOD] 1-Click Flashable exFAT + NTFS + EXT4 support for CM10.1/AOSP + Partitioned SD!

Tip us?
 
HMkX2
Old
(Last edited by HMkX2; 4th August 2013 at 09:55 PM.)
#1  
HMkX2's Avatar
Member - OP
Thanks Meter 127
Posts: 80
Join Date: Jan 2010
Storage [MOD] 1-Click Flashable exFAT + NTFS + EXT4 support for CM10.1/AOSP + Partitioned SD!

August 4th 2013 - This script has not been maintained in a while. A big thank you to Captain_Throwback for providing continued support.

This is now minimally supported.
Now that CM is adding native NTFS/exfat support, the only thing my script handles is multiple partitions.

"HELP! I accidentally made my exFat card unreadable!!" -- or-- "I can't see more than 1 partition in windows!!"

Please read the instructions at the bottom of THIS POST HERE. No data will be lost!

"My card was working up until a moment ago but now the phone is showing "card damaged!!"

Re-run the script by typing "fuse-mountsd.sh" as root. The script will attempt to repair and re-mount.
If that fails, run "chkdsk /f" in Windows. Do not reformat until it is the last resort!
TL;DR: (Flash this), put exFat/FAT32/NTFS/EXT4 sdcard in, reboot.
To remount, type "fuse-mountsd.sh" in a console (or) run using RomToolbox Lite (in /system/xbin/)
Needs to be run every time card is ejected + reinserted -- including when UMS is used

To unmount, type "fuse-mountsd.sh umount" (or if 1 partition) use Storage Manager

Non-customized multi-partitions mounted in /storage/<their name>
  • Uses init.d to fix/mount at boot
  • Scans for/mounts all useable block devices (with safety checks)
  • User-specifiable dynamic mount points
    ~~Create a ".mounthere" file in the partition with the first line "/location/to/mount/at"
    ~~Use the first line "skip" or "SKIP" to bypass that partition
  • Rescans for media when you re-mount
  • Repairs typical exFat damage caused by CM10.1 (with safety nets)
  • FAT32 support
  • NTFS-3g support (noatime set to reduce wear)
  • EXT4/3/2 support (*fuse built into JB/CM10.1) <- (MTP+EXT4 permissions need to be set to media_rw:media:rw 775!!))
  • Cleans up after itself: disables/enables ADB/root-security to what you set


BUGS:

All -- ntfsfix does not work. Binaries need to be recompiled. Not a major issue only dead weight.
exFAT may prevent deep-sleep. (NTFS on GS3 doesn't seem to have this issue.)

If you use EXT4/3/2, you need to run the following commands to allow the card to be accessed by the mobile-user:

Code:
find  /storage/sdcard1/ -print0 | xargs -0 chown media_rw:media_rw
chmod -R 775 /storage/sdcard1/

(or)

find  /storage/sdcard1/ -print0 | xargs -0 chown root:media_rw
Other phones -- Post a debug.txt if it works for you.

CM10 (4.1.x) -- Support is experimental. Use at your own risk.

CM 10.1 (4.2.x) -- Implemented RSA Key Signing Fix, works with BOOTICE.exe partitioned cards.

EXPERTS:
Everything is softcoded thanks to the $SECONDARY_STORAGE, $ANDROID_DATA, $ANDROID_STORAGE, $ANDROID_CACHE env variables and get/setprop command. Some locations are hardcoded in the script's "analyzePhone" function as fallbacks.

To custom-map mountpoints, create a ".mounthere" file in the root of each partition. "skip" or "SKIP" = ignore partition at mount, "/your/path/here" will use that path (or the default if bad). Defaults to "$ANDROID_STORAGE/device_id" if directory is invalid. Removes any temporary directories (in /storage/ only) at unmount. YOU HAVE TO CREATE ANY CUSTOM DIRECTORIES OUTSIDE "/storage" YOURSELF -- I set it like that as a security precaution.

To disable "Directory Creation Security", edit the line at the top of the script to say "dirSECURITY=0". This script will remount / and /storage as RW if needed.
Here is a quick rundown of typical use-cases:
You want one large (exFat/NTFS/ext4) partition:
  • No customization needed, just flash and go

You want a small FAT32 partition (p1) at the beginning (for firmware/CWM/TWRP) with another big ext4 partition (p2) for your SD card mount. [ Your ROM's vold will mount (p1:fat32) as /storage/sdcard1 automatically. To get it to swap over: ]
  • Create a ".mounthere" file on (p2) "big" partition with the text "/storage/sdcard1"
This will override Vold and mount the (p2) as external storage. The FAT32 partition will be mounted in /storage/mmcblk1. If you want to mount it elsewhere (even /data/media/0/extSD ! ) simply add another ".mounthere" on the FAT32 partition. (The directory must already exist -- you must make it beforehand -- or disable Directory Security feature.) Be warned - Vold will mount the first partition as /storage/sdcard1 any chance it gets -- even in the background -- unless there is something mounted there already (by this script).

You have (1) partition for a game app you play (internal storage) that you want to rebind, (2) another part you want to rebind OVER an existing directory, and (3) your main storage.
  • Create a ".mounthere" on (1) with text "/location/of/your/game/app/data"
  • ".mounthere" on (2) with text "/folder/you/want/substituted"
  • ".mounthere" on (3) with text "/storage/sdcard1"

You are a long-hair-hippie Linux developer with 4 partitions, each in a different filesystem, and want them mounted hidden from apps and listed by block device so you know what partition you are on:
  • No customization needed, just flash and go
SUPPORT:

I can only provide support if you supply me with logs. Do so by typing "fuse-mountsd.sh > /sdcard/debug.txt 2>&1" and opening the Debug.txt in your phone's storage.

It's all automatic now - so if it mounts your modem as writeable and kicks your dog don't blame me. (It excludes dangerous block devices automatically [mmcblk0, /system, mtdblock, etc], but there is always a 1% chance it will miss something.) If it does, report it here so I can fix it.

If you intend to use this with a other ROMs/phones, IT SHOULD STILL WORK. Post any errors or weird behavior.

Code:
Changelog

7.0 - TBA (Make GUI? Fix ext4 permissions automatically? Get paid?)

6.4 - No longer uses "mount" output (wasn't acting standard-ly. Using /proc/mounts instead)
    - Got rid of conv=notrunc. Be careful!
6.3 - Bugfix to scrubMount code
6.2 - No longer Experimental / final unstable
    - added rough ext2/3 support
6.1 - mount command bugfix
6.0 - Added a bypass for Directory Security, fixed some bugs.
5.9 - Rewrote NOGO code from scratch -- UUIDs ignored
5.8 - (??)
5.7 - Support for Note2 formatted exFat cards + more (0xf4 bug)
5.6 - bug fixed: no longer detects zram/assumes multimount
5.5 - Experimental support for weird devices
5.4 - Major bugfix!! Fix fixmyexfat.sh coding fail
5.3 - Fixed "vffat" support. Undid HARD QUIT on bad Nogo, made it a soft one.
5.2 - Increased logging of tables, HARD QUIT if Nogo not found
5.1 - Quick patch to fix dm-* device blacklist
5.0 - SUPPORTS MULTI-PARTITIONED CARDS! Autoscans for block devs! Complete rewrite!
4.1 - Quick patch to check mmcblk1
4.0 - WORKS 100% ON 4.2.2!! My script is the first to achieve this AFAIK
3.3 - fixed a bug detecting existing mounts (related to "non-persistent mount points" issue)
3.1 - added dynamic exFAT repair code
3.0 - added NTFS/ext4 support
1.0 -> 2.0 <Removed>
Attribution credits:
Original thanks go to originator of the method, smitna in the Galaxy S2 forum. Additional thanks go to shardul_seth (Post 23) for compiling the latest version of the fuse-exfat and ntfs-3g binaries for ARM, and of course Andrew Nayenko for his efforts in creating GPL'd exFat code (fuse-exfat on google code).

[HOWTO][exFAT][WORK IN PROGRESS] Mount exFAT formatted drives and cards - smitna
Full NTFS Read Write support for Android (ARM) - shardul_seth
[HOWTO][exFAT][CM10.1] Working 64GB ext sdcard with fuse-exfat (1.0.1) + FIX broken (my original Dev thread)


I believe the term is I "kanged" their binaries. The rest is mine. This is a "mod"/"hack" until CM adds native support. (If ever: exFat)
DONATIONS:
https://supporters.eff.org/donate , or help a noob by linking to a solution in their thread.
https://plus.google.com/+CyanogenMod/posts/ib5wz8jk1JyOne of the CM Team has flesh eating bacteria! Keep CM alive! (Literally)
The Following 51 Users Say Thank You to HMkX2 For This Useful Post: [ Click to Expand ]
 
lordazoroth
Old
(Last edited by lordazoroth; 20th February 2013 at 04:43 PM.)
#2  
lordazoroth's Avatar
Senior Member
Thanks Meter 55
Posts: 168
Join Date: Jul 2012
Location: Phoenix
I'm a noob, this looks scary to me. Either way, I needs me some exfat cuz my movies are too large for fat32. :P

My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?

Here's what I'm running:
SGH-T999 (d2tmo)
Android 4.2.2
Kernel: 3.0.62-cyanogenmod-g137df31
ROM: Liquid-JB-v2.1-RC1
Build:liquid-d2tmo-userdebug 4.2.2 JDQ39


I've spent the last 2 days searching and testing to no avail. My sdcard is running hot trying to get files larger than 4gb on it. I've tried formatting to exfat, ntfs, ext4, even hfs+, no success. Paragon and ntfssd apps couldn't mount it either.

Any help on this matter would be greatly appreciated!

Even though this might not work on T-mobile, thank you either way, I'm glad there are people like you developing for 64gb cards.
If I've helped you, please thank me.

My Device:
) T-Mobile Samsung Galaxy S III: Infamous v4.8.2 + KT747-TW-JB-4.1.2-ATT-05-31-2013 Kernel

Retired:
) Sprint Nexus S 4G
 
HMkX2
Old
(Last edited by HMkX2; 20th February 2013 at 08:42 PM.)
#3  
HMkX2's Avatar
Member - OP
Thanks Meter 127
Posts: 80
Join Date: Jan 2010
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.

Quote:
Originally Posted by lordazoroth View Post
My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?
MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.

Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
  1. I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
  2. Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
  3. The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.

If you have any doubts, don't do it.
HMkX2 CORE F6BC 6626 F92A A8F6 72C3 5B4A A301 BF44 08B7 042D
The Following 3 Users Say Thank You to HMkX2 For This Useful Post: [ Click to Expand ]
 
lordazoroth
Old
#4  
lordazoroth's Avatar
Senior Member
Thanks Meter 55
Posts: 168
Join Date: Jul 2012
Location: Phoenix
Quote:
Originally Posted by HMkX2 View Post
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.



MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.

Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
  1. I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
  2. Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
  3. The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.

If you have any doubts, don't do it.
Awesome instructions, very much appreciate it. Looks like it's time to get to work. I checked the zip file thoroughly and cross-checked it with my root directories to see if it overwrites anything and it looks like it just adds stuff. From what I've seen, this is the only game in town so I'll post back once I'm done.

If this does work, this is a godlike zip file and it does something nothing else can do right now
If I've helped you, please thank me.

My Device:
) T-Mobile Samsung Galaxy S III: Infamous v4.8.2 + KT747-TW-JB-4.1.2-ATT-05-31-2013 Kernel

Retired:
) Sprint Nexus S 4G
 
lordazoroth
Old
(Last edited by lordazoroth; 21st February 2013 at 01:43 AM.)
#5  
lordazoroth's Avatar
Senior Member
Thanks Meter 55
Posts: 168
Join Date: Jul 2012
Location: Phoenix
Ok still not mounting properly.

Here's what I did:
Typed "echo $SECONDARY_STORAGE" in a terminal emulator, showed "/storage/sdcard1"

Typed "blkid", showed "/dev/block/mmcblk1p1" only when sd card was inserted under fat32 file format

Formatted sd card to exFAT on PC, inserted back into s3

Flashed CM10.1_exFAT-mountsd_2.0_HMkX2.zip


Ran terminal emulator, typed su >> exfat-mountsd.sh got this:

u0_a70@android:/ $ su
root@android:/ # exfat-mountsd.sh
[exfat-mountsd v2.0] exFat autorepair and mount script for CM10.1 (HMkX2 CORE//XDA)
Automated mounting script for exFat on GS3
/storage/sdcard1 is not mounted. (OK)
Calling [fixmyexfat] on /dev/block/mmcblk1p1 (if needed)
Broadcasting: Intent { act=android.intent.action.MEDIA_CHECKING dat=file:///storage/sdcard1 }
Broadcast completed: result=0
[fixmyexfat v2.0] exFat header repair tool (HMkX2 CORE//XDA)
More robust than before!
Usage: /system/xbin/fixmyexfat.sh <block device, eg /dev/block/mmcblk1p1>
[fixmyexfat] Manual target is /dev/block/mmcblk1p1
1+0 records in
1+0 records out
512 bytes transferred in 0.166 secs (3084 bytes/sec)
Segment 1 (0:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.012 secs (333 bytes/sec)
Segment 2 (484:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.007 secs (571 bytes/sec)
Segment 3 (508:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.005 secs (800 bytes/sec)
Check complete!
Check complete, mounting and initializing...
########################## ATTEMPTING COMMAND ##########################
mount.exfat-fuse -o rw,dirsync,umask=0 /dev/block/mmcblk1p1 /storage/sdcard1
Attempting bypass...
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
connected to localhost:5556
List of devices attached
localhost:5556 device
Running ADB commands
FUSE exfat 1.0.1
ERROR: invalid VBR checksum 0xa04b8eb5 (expected 0x804d6ce4).
Broadcasting: Intent { act=android.intent.action.MEDIA_MOUNTED dat=file:///storage/sdcard1 }
Broadcast completed: result=0
Process complete!
root@android:/ #


Not sure how to read this...

Afterwards my notification panel says: "Damaged SD card : SD card is damaged. Try reformatting it."

Tried restarting s3, mounting in storage settings, reformatting in PC. Ran script 4 times on a fresh exFAT format with the same notification error (format was unrecognizable by s3 and PC after running terminal command "exfat-mountsd.sh" [don't worry didn't lose any data :P]).

After each format to exFAT on my PC I placed a few images on the card to ensure it was functioning properly, /storage/sdcard1 directory is always empty.

Mounting in settings >> storage generates the same notification error: "Damaged SD card : SD card is damaged. Try reformatting it."

Any ideas?... it is detecting an SD there after mount attempts (despite exFAT format) interestingly enough. Though nothing is detected after a reboot unless another script or settings >> storage mount attempt is performed.

I should mention that I ran a "quick" format when formatting the SD card from Fat32 to exFAT, not sure if that might be relevant.
If I've helped you, please thank me.

My Device:
) T-Mobile Samsung Galaxy S III: Infamous v4.8.2 + KT747-TW-JB-4.1.2-ATT-05-31-2013 Kernel

Retired:
) Sprint Nexus S 4G
The Following User Says Thank You to lordazoroth For This Useful Post: [ Click to Expand ]
 
HMkX2
Old
(Last edited by HMkX2; 21st February 2013 at 04:22 AM.)
#6  
HMkX2's Avatar
Member - OP
Thanks Meter 127
Posts: 80
Join Date: Jan 2010
Hm... well, I can tell you what it means. Quick formatting is fine, I actually prefer it since flash memory has a limited life. Second, "chkdsk /f" in windows will repair your card + data -- the card isn't "damaged", it's just that 4 letters at the beginning were changed. (See: Segment1, Segment2, Segment 3 messages.) My scripts change those 4 letters back, in a safe-ish way.

Unfortunately, without having a hex-dump of your working exFat header I can't say what those four letters should be. I got mine using a program called Hex Editor Neo on what I had available, a Sandisk 64gb class-10, and are what I included in the script. When the letters don't line up like it expects, you get a checksum error.

Without that, there is one single thing you can try - but has a high likelyhood of success.
  1. Use RootBox explorer, navigate to /system/xbin/ and DELETE the file called "fixmyfat.sh".
  2. Turn your phone OFF. Eject the SD card
  3. chkdsk /f the card or quick format it to fix it, put a test file on it from Windows
  4. Put the card in your phone, turn on.The card must be in the phone before it is turned on.

If that works for you, and the card works, you can give me a hex dump pretty easily so I can edit the script. IF it works, and I highly suspect it will, get a hex dump by typing EXACTLY:
dd if=/dev/block/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin
<- corrected

That will place a text file in your internal sd card than you can post/send me. Again, thanks for bearing with me, this started out as something for myself then made better in the hopes other people could use it. If you could re-corrupt the card (by unplugging/replugging it while the phone is on) and send me a hex dump of the "Card Damaged" state, even better.
HMkX2 CORE F6BC 6626 F92A A8F6 72C3 5B4A A301 BF44 08B7 042D
The Following User Says Thank You to HMkX2 For This Useful Post: [ Click to Expand ]
 
lordazoroth
Old
(Last edited by lordazoroth; 21st February 2013 at 04:21 AM.)
#7  
lordazoroth's Avatar
Senior Member
Thanks Meter 55
Posts: 168
Join Date: Jul 2012
Location: Phoenix
O.O... you are awesome!

I'll get on this right away, and I'd be happy to help any way i can

---------- Post added at 09:19 PM ---------- Previous post was at 08:52 PM ----------

OMG IT WORKS!!! the card mounted

I tried the line of code and it gave me an error:

u0_a70@android:/ $ su
root@android:/ # dd if=/dev/blk/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin
/dev/blk/mmcblk1p1: cannot open for read: No such file or directory
1|root@android:/ #

My /sdcard directory seems to be a redirect to /storage/sdcard0 (i think), i have a lot of these (what appear to be redirects) on my phone now after upgrading from android 4.0.4 to 4.2.2. If I changed the end of that line of code to something like "of=/storage/sdcard0/0//working_sd.bin" (or any similar working directory), might that solve the problem or am I reading that wrong?

Thank you so much, this is... very powerful!
Great work on this!
If I've helped you, please thank me.

My Device:
) T-Mobile Samsung Galaxy S III: Infamous v4.8.2 + KT747-TW-JB-4.1.2-ATT-05-31-2013 Kernel

Retired:
) Sprint Nexus S 4G
 
HMkX2
Old
(Last edited by HMkX2; 21st February 2013 at 04:47 AM.)
#8  
HMkX2's Avatar
Member - OP
Thanks Meter 127
Posts: 80
Join Date: Jan 2010
Double post.
The Following User Says Thank You to HMkX2 For This Useful Post: [ Click to Expand ]
 
HMkX2
Old
#9  
HMkX2's Avatar
Member - OP
Thanks Meter 127
Posts: 80
Join Date: Jan 2010
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.

I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.

And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
HMkX2 CORE F6BC 6626 F92A A8F6 72C3 5B4A A301 BF44 08B7 042D
The Following User Says Thank You to HMkX2 For This Useful Post: [ Click to Expand ]
 
lordazoroth
Old
(Last edited by lordazoroth; 21st February 2013 at 06:31 AM.)
#10  
lordazoroth's Avatar
Senior Member
Thanks Meter 55
Posts: 168
Join Date: Jul 2012
Location: Phoenix
Quote:
Originally Posted by HMkX2 View Post
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.

I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.

And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
Sounds bad, I don't know why all these companies are sticking with Fat32 after all these years. Fat32 has been obsolete since like 2000, don't we have open source formats like ext4 now? - that's my rant lol. Either way, it works and I got the file. Btw, this file acts strangely on my device, I couldn't see it in windows explorer during plugin and It wouldn't copy to my sd card even though other files seem to be copying fine. Had to email it to myself from my phone. Thank you so much for all your help, let me know if you need anything else

Rename the file and remove .rar extension before use, xda doesn't allow .bin extensions to be uploaded.

Quick question: If I shut the phone down and pull the SD, can I turn the phone back on and use it without the SD while I load the SD up with files, then power off, re-insert the SD and power on again? (like will it automount again?)
Attached Files
File Type: rar working_sd.bin.rar - [Click for QR Code] (512 Bytes, 139 views)
If I've helped you, please thank me.

My Device:
) T-Mobile Samsung Galaxy S III: Infamous v4.8.2 + KT747-TW-JB-4.1.2-ATT-05-31-2013 Kernel

Retired:
) Sprint Nexus S 4G

The Following User Says Thank You to lordazoroth For This Useful Post: [ Click to Expand ]
Tags
cm10.1, exfat, ext4, external card, ntfs
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes