NTFS on your android with full read write support

Search This thread

munjeni

Senior Member
Jun 2, 2011
9,514
22,155
How to install this:

1. put copymodulecrc to the /data/local/tmp folder and chmod them to 755
(adb shell chmod 755 /data/local/tmp/copymodulecrc)

2. put ntfs-3g and ntfsmount to the folder /system/bin and chmod them to 755
(adb shell chmod 755 /system/bin/ntfs-3g)
(adb shell chmod 755 /system/bin/ntfsmount)

3. put sdcardfs.ko to the folder /system/lib/modules and chmod them to 644
(adb shell chmod 644 /system/lib/modules/sdcardfs.ko)

What is next? Next:

1. in order to get it working, sdcardfs.ko must be patched to match your kernel version since every kernel modules is paired with kernel by version string, so if version string not match module version it will not work! So you must patch sdcardfs.ko module using tool called copymodulecrc! Copymodulecrc will extract version string from any module of the your stockrom kernel modules and copy them directly to the sdcardfs.ko (patch them). First of all you need to look into your /system/lib/modules folder and use any .ko file NAME for referencie in next commands:
Code:
adb shell /data/local/tmp/copymodulecrc /system/lib/modules/PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES /system/lib/modules/sdcardfs.ko
So replace PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES with the name of the any module you found in modules folder! Done.
2. if you completed step 1 without errors you are ready for this step. You need to locate script called install-recovery.sh (on most devices it is in folder /system/etc) and add next lines:
Code:
insmod /system/lib/modules/sdcardfs.ko
Done. On every next reboot sdcardfs kernel module will be automatically included in your kernel.
3. if you get error in patching sdcardfs.ko whole thing will not work! So these step is important! You can verify success by command: (su -c "insmod /system/lib/modules/sdcardfs.ko") , if you see error than sdcardfs is not working, if you see nothing than it is working :)

Since you completed these 3 things, you are ready to use NTFS volumes on your device! To understand these things:

1. first of all, you can not mount ntfs volume regulary trought settings menu since android not support ntfs by default! You must mount/umount your ntfs volume manually (you can use for example android terminal emulator when you need to mount/umount ntfs). You will not see any details about ntfs volume in settings menu since android not support ntfs by default, you can see details in most file managers only.

How to mount and unmount:

1. to mount (first connect your usb ntfs volume to your device usb port) :
Code:
su -c "ntfsmount mount"
Done! Your ntfs volume by these command is mounted and you are ready to read/write them using your faworite file manager :)
2. To umount (do in mind - every time before you going to remove ntfs volume from your device you must unmount it!):
Code:
su -c "ntfsmount umount"
Done! You are ready to remove ntfs volume from your usb port.

NTFS on sdcard? Yes but you need to modify a bit ntfsnount script! Don't ask me how ypu can modify them, do it byself!

Since somebody complain here about gpl licence, I am not ready ready to share sdcardfs source code with you since it is not gpl licenced, instead it is apache 2.0 licenced by Samsung guys @ 2013 and I no need to share it with you since you wanted to see them forced! I not like when somebody forcing me for something! Find it, patch them, make module of them byself ;)

ntfs-3g is not compiled by me, it is used from here -> http://forum.xda-developers.com/showthread.php?t=1724078

ntfsmount script is created by me.

Copymodulecrc I do not know where I found them but here is source code:
Code:
/* copymodulecrc */

/*
 * Copyright (C) 2014 CUBE
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>


int main(int argc, char **argv) {
	struct stat st;
	off_t filesize;
	int fd;
	char *data, *pos;
	unsigned int i;
	int bFound;
	unsigned long crcval;

	if (argc != 3) {
		printf("usage: copymodulecrc [modulename(src)] [modulename(dst)]\n");
		return -1;
	}

	if (stat(argv[1], &st) != 0) {
		fprintf(stderr, "module1 stat failed.\n");
		return -1;
	}
	filesize = st.st_size;
	fd = open(argv[1], O_RDONLY);
	if (fd < 0) {
		fprintf(stderr, "module1 open failed.\n");
		return -1;
	}
	data = mmap(NULL, filesize, PROT_READ, MAP_SHARED, fd, 0);
	if (data == MAP_FAILED) {
		fprintf(stderr, "module1 mmap failed.\n");
		close(fd);
		return -1;
	}
	pos = data;
	bFound = 0;
	for (i = 0; i < (filesize - 12); ++i) {
		if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
			bFound = 1;
			break;
		}
		pos++;
	}
	if (bFound == 0) {
		fprintf(stderr, "module1 crc not found.\n");
		munmap(data, filesize);
		close(fd);
		return -1;
	}

	pos -= 4;
	memcpy((void *)&crcval, (void *)pos, 4);

	munmap(data, filesize);
	close(fd);

	printf("module crc=%08x\n", (unsigned int)crcval);

	if (stat(argv[2], &st) != 0) {
		fprintf(stderr, "module2 stat failed.\n");
		return -1;
	}
	filesize = st.st_size;
	fd = open(argv[2], O_RDWR);
	if (fd < 0) {
		fprintf(stderr, "module2 open failed.\n");
		return -1;
	}
	data = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	if (data == MAP_FAILED) {
		fprintf(stderr, "module2 mmap failed.\n");
		close(fd);
		return -1;
	}
	pos = data;
	bFound = 0;
	for (i = 0; i < (filesize - 12); ++i) {
		if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
			bFound = 1;
			break;
		}
		pos++;
	}
	if (bFound == 0) {
		fprintf(stderr, "module2 crc not found.\n");
		munmap(data, filesize);
		close(fd);
		return -1;
	}

	pos -= 4;
	memcpy((void *)pos, (void *)&crcval, 4);

	munmap(data, filesize);
	close(fd);

	printf("module crc copied.\n");

	return 0;
}

And finaly, files you need to install is in attachment, enjoy! ;)
 

Attachments

  • files.rar
    643 KB · Views: 11,947
Last edited:

anonyo

Senior Member
Feb 10, 2014
73
27
Just need some clarification, when you say NTFS support, do you mean read and write or just read-only?
 
  • Like
Reactions: chdeng

nag4pl

Senior Member
Dec 6, 2013
76
50
Bangalore
Not going to explain in details, here is my tool which will add ntfs support to your android, run them and folow instructions! If you unable to patch sdcardfs.ko kernel module (giving you error when you doing insmod) than the whole things will not work on your device :( Curntly tested device is Xperia Z1 Compact on android version 14.4.A.0.108! Important thing is having sdcardfs installable, the rest is easy.

In order to have sdcardfs module insmoded on every reboot, you need to add one line into /system/etc/install-recovery.sh :


The rest of the tutorial you can see under application. Enjoy if you find this usefull! :)

/system/etc/install-recovery.sh :-
- install-recovery.sh file is not available at /system/etc/.
- Is it possible to create the file and then we can insert the line?

Am using AOSP - Carbon ROM on Xperia Z..

Thank you!!
 

Moscow Desire

Retired Senior Moderator
Just a heads up..

On Xperia Z2 tablet with 4.4.2, connected to 1tb NTFS drive.

After modding the ko and setting all permissions, rebooting, will only "half-mount" the drive. It sees it, recognizes it, but claims drive is empty (wants to format it).

Status bar displays "Empty USB Storage"

In settings, when selecting Mount USB Storage, it briefly acts like it will mount. for a split second.

Any files I can get that can possibly help?

UPDATE: After running the mount commands via terminal, now it seems to mount it via ES File explorer. Although it sometimes still gives me the message in statusbar.

But seems to be working well.
 
Last edited:
  • Like
Reactions: mirhl

Moscow Desire

Retired Senior Moderator
Seeing as this patches a kernel module will it work on rooted phones with a locked bootloader?

My Z2 Tablet has a locked bootloader. So yes, it should. There's nothing going on that warrants an unlocked bootloader. Just the addition of some files and permission changes, which are normal with a rooted device.
 

Moscow Desire

Retired Senior Moderator
Also note, that in the Settings\Storage, it will not show up as being "mounted". At least not in my case. However, ES File Explorer has no issue with it, and shows as a USB 1052 drive under the "Local" menu. Navigation seems normal within the drive.

I get the "USB Drive Empty or Unsupported" message in the status bar, for a few seconds, but the ES FE displays the drive contents, and the message goes away after it reads drive contents. Note that it may assign a different drive identifier each time you use it.

In testing I have found apps from the market;

StickMount does not work at all on my Stock OS.
Paragon NTFS mount works, but it runs as a system process using memory and probably battery.

This mod seems to work, for the most part, as long as you use ES File Explorer.
 

spoidar

Senior Member
Aug 13, 2010
153
59
OP - you must provide the source for any modified code covered by the GPL that you are distributing - that includes the sdcardfs kernel module, and the ntfs-3g binary. Packing them in an encrypted Windows executable does not help.
 
  • Like
Reactions: BROKEN1981

Moscow Desire

Retired Senior Moderator
OP - you must provide the source for any modified code covered by the GPL that you are distributing - that includes the sdcardfs kernel module, and the ntfs-3g binary. Packing them in an encrypted Windows executable does not help.

No he doesn't. Only the zimage (kernel) is covered under GPL.

UPDATE: Just to clarify, the matter "Has" been brought to the Developers Committee to address any possible GPL violations. The DC is more informed on GPL.
 
Last edited:
  • Like
Reactions: kevp75

coolrevi

Senior Member
Jun 1, 2012
637
146
Udupi
Need help here

After i Copy copymodulecrc and sdcardfs.ko to /data/local/tmp and gave the permission as rwx-r-r to copymodulecrc. how to run it? can anybody help me here to patch sdcardfs.ko
 

Moscow Desire

Retired Senior Moderator
After i Copy copymodulecrc and sdcardfs.ko to /data/local/tmp and gave the permission as rwx-r-r to copymodulecrc. how to run it? can anybody help me here to patch sdcardfs.ko

First off, permissions must be set to 755 (rwx-rx-rx) if I'm not mistaken. Root Explorer converts it to the numerical format when you change permissions.

Next, use a terminal program (available from the play store) Make sure you run it as SU. (type SU + Enter, you will get the # sign) Then type in the commands and paths as indicated. (I copied and pasted my paths)
 
  • Like
Reactions: rjl101

coolrevi

Senior Member
Jun 1, 2012
637
146
Udupi
First off, permissions must be set to 755 (rwx-rx-rx) if I'm not mistaken. Root Explorer converts it to the numerical format when you change permissions.

Next, use a terminal program (available from the play store) Make sure you run it as SU. (type SU + Enter, you will get the # sign) Then type in the commands and paths as indicated. (I copied and pasted my paths)

I got it till replacing a line in install-recovery.sh but i am stuck there as there is no line called ntfs.ko to replace with
 
Last edited:

anandisrocking007

Senior Member
Mar 4, 2013
297
122
29
Kolkata
I am recieving the error in the screenshot
The device that i am using is Lenovo A3500HV which contains a Jellybean 4.2.2 AOSP ROM (Hardly any modification)

Please Help

attachment.php
 

Attachments

  • Screenshot_2014-11-04-13-05-28.png
    Screenshot_2014-11-04-13-05-28.png
    76.2 KB · Views: 4,146

Top Liked Posts

  • There are no posts matching your filters.
  • 57
    How to install this:

    1. put copymodulecrc to the /data/local/tmp folder and chmod them to 755
    (adb shell chmod 755 /data/local/tmp/copymodulecrc)

    2. put ntfs-3g and ntfsmount to the folder /system/bin and chmod them to 755
    (adb shell chmod 755 /system/bin/ntfs-3g)
    (adb shell chmod 755 /system/bin/ntfsmount)

    3. put sdcardfs.ko to the folder /system/lib/modules and chmod them to 644
    (adb shell chmod 644 /system/lib/modules/sdcardfs.ko)

    What is next? Next:

    1. in order to get it working, sdcardfs.ko must be patched to match your kernel version since every kernel modules is paired with kernel by version string, so if version string not match module version it will not work! So you must patch sdcardfs.ko module using tool called copymodulecrc! Copymodulecrc will extract version string from any module of the your stockrom kernel modules and copy them directly to the sdcardfs.ko (patch them). First of all you need to look into your /system/lib/modules folder and use any .ko file NAME for referencie in next commands:
    Code:
    adb shell /data/local/tmp/copymodulecrc /system/lib/modules/PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES /system/lib/modules/sdcardfs.ko
    So replace PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES with the name of the any module you found in modules folder! Done.
    2. if you completed step 1 without errors you are ready for this step. You need to locate script called install-recovery.sh (on most devices it is in folder /system/etc) and add next lines:
    Code:
    insmod /system/lib/modules/sdcardfs.ko
    Done. On every next reboot sdcardfs kernel module will be automatically included in your kernel.
    3. if you get error in patching sdcardfs.ko whole thing will not work! So these step is important! You can verify success by command: (su -c "insmod /system/lib/modules/sdcardfs.ko") , if you see error than sdcardfs is not working, if you see nothing than it is working :)

    Since you completed these 3 things, you are ready to use NTFS volumes on your device! To understand these things:

    1. first of all, you can not mount ntfs volume regulary trought settings menu since android not support ntfs by default! You must mount/umount your ntfs volume manually (you can use for example android terminal emulator when you need to mount/umount ntfs). You will not see any details about ntfs volume in settings menu since android not support ntfs by default, you can see details in most file managers only.

    How to mount and unmount:

    1. to mount (first connect your usb ntfs volume to your device usb port) :
    Code:
    su -c "ntfsmount mount"
    Done! Your ntfs volume by these command is mounted and you are ready to read/write them using your faworite file manager :)
    2. To umount (do in mind - every time before you going to remove ntfs volume from your device you must unmount it!):
    Code:
    su -c "ntfsmount umount"
    Done! You are ready to remove ntfs volume from your usb port.

    NTFS on sdcard? Yes but you need to modify a bit ntfsnount script! Don't ask me how ypu can modify them, do it byself!

    Since somebody complain here about gpl licence, I am not ready ready to share sdcardfs source code with you since it is not gpl licenced, instead it is apache 2.0 licenced by Samsung guys @ 2013 and I no need to share it with you since you wanted to see them forced! I not like when somebody forcing me for something! Find it, patch them, make module of them byself ;)

    ntfs-3g is not compiled by me, it is used from here -> http://forum.xda-developers.com/showthread.php?t=1724078

    ntfsmount script is created by me.

    Copymodulecrc I do not know where I found them but here is source code:
    Code:
    /* copymodulecrc */
    
    /*
     * Copyright (C) 2014 CUBE
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     *
     */
    
    #include <stdio.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <sys/mman.h>
    
    
    int main(int argc, char **argv) {
    	struct stat st;
    	off_t filesize;
    	int fd;
    	char *data, *pos;
    	unsigned int i;
    	int bFound;
    	unsigned long crcval;
    
    	if (argc != 3) {
    		printf("usage: copymodulecrc [modulename(src)] [modulename(dst)]\n");
    		return -1;
    	}
    
    	if (stat(argv[1], &st) != 0) {
    		fprintf(stderr, "module1 stat failed.\n");
    		return -1;
    	}
    	filesize = st.st_size;
    	fd = open(argv[1], O_RDONLY);
    	if (fd < 0) {
    		fprintf(stderr, "module1 open failed.\n");
    		return -1;
    	}
    	data = mmap(NULL, filesize, PROT_READ, MAP_SHARED, fd, 0);
    	if (data == MAP_FAILED) {
    		fprintf(stderr, "module1 mmap failed.\n");
    		close(fd);
    		return -1;
    	}
    	pos = data;
    	bFound = 0;
    	for (i = 0; i < (filesize - 12); ++i) {
    		if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
    			bFound = 1;
    			break;
    		}
    		pos++;
    	}
    	if (bFound == 0) {
    		fprintf(stderr, "module1 crc not found.\n");
    		munmap(data, filesize);
    		close(fd);
    		return -1;
    	}
    
    	pos -= 4;
    	memcpy((void *)&crcval, (void *)pos, 4);
    
    	munmap(data, filesize);
    	close(fd);
    
    	printf("module crc=%08x\n", (unsigned int)crcval);
    
    	if (stat(argv[2], &st) != 0) {
    		fprintf(stderr, "module2 stat failed.\n");
    		return -1;
    	}
    	filesize = st.st_size;
    	fd = open(argv[2], O_RDWR);
    	if (fd < 0) {
    		fprintf(stderr, "module2 open failed.\n");
    		return -1;
    	}
    	data = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    	if (data == MAP_FAILED) {
    		fprintf(stderr, "module2 mmap failed.\n");
    		close(fd);
    		return -1;
    	}
    	pos = data;
    	bFound = 0;
    	for (i = 0; i < (filesize - 12); ++i) {
    		if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
    			bFound = 1;
    			break;
    		}
    		pos++;
    	}
    	if (bFound == 0) {
    		fprintf(stderr, "module2 crc not found.\n");
    		munmap(data, filesize);
    		close(fd);
    		return -1;
    	}
    
    	pos -= 4;
    	memcpy((void *)pos, (void *)&crcval, 4);
    
    	munmap(data, filesize);
    	close(fd);
    
    	printf("module crc copied.\n");
    
    	return 0;
    }

    And finaly, files you need to install is in attachment, enjoy! ;)
    3
    Seeing as this patches a kernel module will it work on rooted phones with a locked bootloader?

    My Z2 Tablet has a locked bootloader. So yes, it should. There's nothing going on that warrants an unlocked bootloader. Just the addition of some files and permission changes, which are normal with a rooted device.
    2
    Does this work with native Android 8.1 Oreo ?
    2
    Thread rewriten and is alive again, instructions in OP updated in details, enjoy!
    1
    Just need some clarification, when you say NTFS support, do you mean read and write or just read-only?