[HACK] mount sdcard as ext4

Search This thread

DebauchedSloth

Senior Member
Jan 27, 2008
459
76
These patches add ext4 support for your sdcard (in the Nexus S - the internal card.) There are a number of reasons you might want to do this - performance (ext4 is faster, plus mounting ext4 is basically instantaneous, which is very nice on reboots...no more checking sdcard), it's more efficient, you get a bunch of file system security features (if you care...)

You should not apply them if you don't really know what you are doing. The patches are resonably benign. Converting your sdcard partition to ext4 is NOT NOT NOT benign and you can really hose yourself doing it.

I'm not going into great depth with these instructions. If you don't understand them, play around with building cyanogen, installing it, etc until they are crystal clear.

To swap your sdcard to ext4:

* Apply the patches and rebuild cyanogen. Rebuild it. They will change your recovery image and vold.

* Install vold and flash (and/or boot) the recovery image.

* Boot into recovery, mount your sdcard and back it up to your computer (i.e., not nandroid, copy the files.) Nandroid would be a good idea too.

* Format your media partition to ext4 (the one that is vfat, by-name is media, mine is partition 3) mkfs.ext4 can be found by googling, or you can use make_ext4fs from /system/bin. I used mkfs.ext4.

* You should be able to manually mount that.

* Push your files back.

* sync and reboot.

Et Voila, you should have an ext4 sdcard partition.

THIS IS VERY DANGEROUS.

YOU CAN REALLY HOSE YOURSELF DOING IT.

Here are the patches:

http://review.cyanogenmod.com/#change,1705

This one adds ext4 support to vold, thus allowing gingerbread to mount ext4 partitions for the sdcard (which on the Nexus S, is the 'media' partition.)

and:

http://review.cyanogenmod.com/#change,1716

This is a change to recovery, making it seamlessly mount ext4 partitions for /sdcard.

Code:
# mount
/dev/block/platform/s3c-sdhci.0/by-name/system on /system type ext4 (ro,noatime,barrier=1,data=ordered,noauto_da_alloc)
/dev/block/platform/s3c-sdhci.0/by-name/userdata on /data type ext4 (rw,nosuid,nodev,noatime,barrier=0,data=ordered)
[b]/dev/block/vold/179:3 on /mnt/sdcard type ext4 (rw,nosuid,nodev,noexec,noatime,barrier=1,data=ordered,noauto_da_alloc)[/b]
/dev/block/vold/179:3 on /mnt/secure/asec type ext4 (rw,nosuid,nodev,noexec,noatime,barrier=1,data=ordered,noauto_da_alloc)
tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
 
Last edited:

DebauchedSloth

Senior Member
Jan 27, 2008
459
76
....and if you turn on USB Storage, the sdcard shows up as an ext4 disk...

As expected, but this is going to be one for the Linux geeks.

Wow, it is VERY nice to have that sdcard mount instantly on boot. VERY nice.
 
  • Like
Reactions: ratsz

DebauchedSloth

Senior Member
Jan 27, 2008
459
76
If anyone is interested in playing with this, I submitted the change to cyanogen:

http://review.cyanogenmod.com/#change,1705

The tricky bit is getting the filesystem created. You can use:

/system/bin/make_ext4fs.

That leaves me with a recovery which will not currently mount sdcard as ext4 unless I fiddle with fstab and mount it myself. On to look at that.
 

drziddo

Senior Member
Jun 15, 2010
555
60
Please some of the genius here may post a step-by-step tutorial or howto for this one? It will be very apreciated.
 

DebauchedSloth

Senior Member
Jan 27, 2008
459
76
No, it will work with any build, but you need to rebuild vold in order to get it to mount. The easiest way to get them outside of the CM tree would be to build cm and then copy the vold out and use that. It should work with any ROM.

The latest versions - which are in CM's gerrit - include modifications to the sdcard utility to use fuse to mount the filesystem using FAT semantics (i.e. - bypass security). Frankly, this is a waste. It slows everything down, noticeably, and app problems are few and easily fixed if you know how to fire off a chmod.

I haven't provided step by step instructions since it can seriously hose your phone if you don't know what you are doing.
 

Anderdroid

Senior Member
Dec 25, 2009
1,211
96
Palo Alto
ninjafighteronline.com
No, it will work with any build, but you need to rebuild vold in order to get it to mount. The easiest way to get them outside of the CM tree would be to build cm and then copy the vold out and use that. It should work with any ROM.

The latest versions - which are in CM's gerrit - include modifications to the sdcard utility to use fuse to mount the filesystem using FAT semantics (i.e. - bypass security). Frankly, this is a waste. It slows everything down, noticeably, and app problems are few and easily fixed if you know how to fire off a chmod.

I haven't provided step by step instructions since it can seriously hose your phone if you don't know what you are doing.

Wait so it's a waste? It isn't worth using ?
 

DebauchedSloth

Senior Member
Jan 27, 2008
459
76
Using the version I posted to CM gerrit, which bounces the file system through fuse and mimics FAT security, is still better than FAT (IMO), but it's not nearly as fast as just mounting the filesystem as Ext4 - though it is more compatible.

I've been running mine mounted as straight ext4 for a couple of weeks. Probably the single best mod I've made to any of my phones. There are occasional app bits that I need to fix manually (such Dropbox resetting file ownership), but it's worth it for the quicker boot up and faster overall operation.
 

td0s

Member
Jun 9, 2009
33
5
Is the only reason to pipe it through fuse to get it to mount on m$? If so I'm not going to bother - I only use linux almost exclusively these days
 

jamiemac1977

Senior Member
Jan 7, 2011
90
7
London, UK
Looking forward to this develpoing, as the ext4 conversion (done via modaco rom beta2 in recoverymode) made a HUGE difference to the galaxy tab i have (halved the loading times of everything). ^^

Unfortunately im far to noob to help out though ...will be keeping a keen eye on it all and learning :D
 

deyna

Senior Member
Dec 14, 2010
94
9
Hernando, MS
Forgive my ignorance, but why don't phones come like this?

window$ more then likely.
window$ can't even see Linux file systems without special drivers installed.


if i mess this up would it brick my phone? i'm really wanting to try this but i don't want to turn my Nexus S into a paperweight
 
Last edited:

NicholasQ

Senior Member
Oct 16, 2010
919
344
so if we did this, would the windows computer be able to read the mounted sd card? is there any other things that would be needed after this mod? or just format to ext4 and be done with it?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    These patches add ext4 support for your sdcard (in the Nexus S - the internal card.) There are a number of reasons you might want to do this - performance (ext4 is faster, plus mounting ext4 is basically instantaneous, which is very nice on reboots...no more checking sdcard), it's more efficient, you get a bunch of file system security features (if you care...)

    You should not apply them if you don't really know what you are doing. The patches are resonably benign. Converting your sdcard partition to ext4 is NOT NOT NOT benign and you can really hose yourself doing it.

    I'm not going into great depth with these instructions. If you don't understand them, play around with building cyanogen, installing it, etc until they are crystal clear.

    To swap your sdcard to ext4:

    * Apply the patches and rebuild cyanogen. Rebuild it. They will change your recovery image and vold.

    * Install vold and flash (and/or boot) the recovery image.

    * Boot into recovery, mount your sdcard and back it up to your computer (i.e., not nandroid, copy the files.) Nandroid would be a good idea too.

    * Format your media partition to ext4 (the one that is vfat, by-name is media, mine is partition 3) mkfs.ext4 can be found by googling, or you can use make_ext4fs from /system/bin. I used mkfs.ext4.

    * You should be able to manually mount that.

    * Push your files back.

    * sync and reboot.

    Et Voila, you should have an ext4 sdcard partition.

    THIS IS VERY DANGEROUS.

    YOU CAN REALLY HOSE YOURSELF DOING IT.

    Here are the patches:

    http://review.cyanogenmod.com/#change,1705

    This one adds ext4 support to vold, thus allowing gingerbread to mount ext4 partitions for the sdcard (which on the Nexus S, is the 'media' partition.)

    and:

    http://review.cyanogenmod.com/#change,1716

    This is a change to recovery, making it seamlessly mount ext4 partitions for /sdcard.

    Code:
    # mount
    /dev/block/platform/s3c-sdhci.0/by-name/system on /system type ext4 (ro,noatime,barrier=1,data=ordered,noauto_da_alloc)
    /dev/block/platform/s3c-sdhci.0/by-name/userdata on /data type ext4 (rw,nosuid,nodev,noatime,barrier=0,data=ordered)
    [b]/dev/block/vold/179:3 on /mnt/sdcard type ext4 (rw,nosuid,nodev,noexec,noatime,barrier=1,data=ordered,noauto_da_alloc)[/b]
    /dev/block/vold/179:3 on /mnt/secure/asec type ext4 (rw,nosuid,nodev,noexec,noatime,barrier=1,data=ordered,noauto_da_alloc)
    tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
    2
    Just applied this mod the my captivate, and it seems to work fine.
    Ill try to make an app based on the above link...

    Edit: App Made (see attachment)
    Just add the directories you want to monitor, and click start. When it notices that a file has been added then it "chmod 777" it.
    By default the app loads up all the sdcard direcories, any changes you make will be saved. (Clear data to get it to relist the sdcard dirs).
    Note: Slide to the right to delete an item. Auto startup comming soon
    2
    It is pretty easy. You need a linux box and nexuss. Make a full sdcard backup before proceeding.
    1. Plug the phone into linux box, push "use as disk" button and discover plugged partition by doing
    Code:
    linux:#dmesg
    in terminal. Let it be /dev/sdb
    2. Repartition sdcard if you need by
    Code:
    linux:#cfdisk /dev/sdb
    or
    Code:
    linux:#fdisk /dev/sdb
    3. Make it ext4 by
    Code:
    linux:#mkfs.ext4 /dev/sdb
    That's all! Reboot your nexuss in recovery mode. The first problem is that recovery couldn't mount sdcard but you could do it manually. Just start adb shell in linux box and type
    Code:
    adb:#mount /dev/block/mmcblk0p3 /mnt/sdcard
    4. Ok it is mounted and recovery could read it. In adb shell
    Code:
    adb:#chmod -R 777 /mnt/sdcard
    . This command make everything world-wide readable-writeable except /mnt/sdcard/.android_secure.
    5. Boot your phone up and you are almost lucky.
    6. Recover sdcard from backup.

    But some applications refuse to properly work and it is matter of permissions. For example camera and gallery got permission denied. Some apps got FC. You have to monitor logcat messages in case of FC or incorrect application behavoir and change permissions accordingly. And do not forget clear app cache after changing permission.

    We have done native mounting here with full linux permission scheme. Don't know about "dirty" mounting with fuse to bypass ext4 security. Also don't forget that Windows-based boxes couldn't operate with your sdcard without third-party drivers and software anymore.
    1
    ....and if you turn on USB Storage, the sdcard shows up as an ext4 disk...

    As expected, but this is going to be one for the Linux geeks.

    Wow, it is VERY nice to have that sdcard mount instantly on boot. VERY nice.
    1
    this is an old thread ... bring it back again to life.....
    hi folks
    I wanted to check for Android 7.0 is there any magic module out there that will Mount EXT 4 partitions at boot time just like the regular exFat f2f s of internal storage.
    I partition my micro SD card into 3 ext4 partitions .
    I can load one using app2sd but if i change the Mount script add similar commands for the other two to block devices they will not mount.

    has someone been in these exact shoes and succeeded mounting ext4 partitions with v o l d support (Android component that makes other applications aware that this drive is available )