Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,781,506 Members 39,512 Now Online
XDA Developers Android and Mobile Development Forum

[HOWTO] Optimal ext4 mount options

Tip us?
 
hardcore
Old
(Last edited by hardcore; 26th October 2010 at 09:34 AM.)
#1  
Senior Member - OP
Thanks Meter 8,146
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Default [HOWTO] Optimal ext4 mount options

Hi guys,

Now that several lagfixes are using the ext4 filesystem, perhaps we should look at optimizing ext4 for performance and lifespan of the flash memory.

One of the main things we can change is the journaling method to data=writeback. This should reduce writes and improve performance at a slight expense of reliability. Quote:

"In data=writeback mode, ext4 does not journal data at all. This mode provides a similar level of journaling as that of XFS, JFS, and ReiserFS in its default mode - metadata journaling. A crash+recovery can cause incorrect data to appear in files which were written shortly before the crash. This mode will typically provide the best ext4 performance."

One explanation here:
http://blog.smartlogicsolutions.com/...m-performance/
Reference here:
http://git.kernel.org/?p=linux/kerne...8986f7;hb=HEAD

HOW TO

1. Change the default mount option of the partition using tune2fs. You need to use a version of tune2fs that supports ext4, the one in busybox 1.17 does NOT. A working version is attached to this post.

- Push the tune2fs file to the phone's SD CARD:
adb push tune2fs /sdcard/

- Copy the tune2fs file to /data/
adb shell
su
cp /sdcard/tune2fs /data/

Now change the options:

/data/tune2fs -o journal_data_writeback /dev/block/mmcblk0p2

To verify:
/data/tune2fs -l /dev/block/mmcblk0p2

Look for the line that says:
Default mount options: journal_data_writeback

* Repeat the above for all other ext4 partitions.

It should take effect after a reboot. The next time it will be mounted automatically with data=writeback. You might have to do the tune2fs settings and reboot twice to get it to stick - I'm not sure why, but I had to.

You can verify this using the mount command:

# busybox mount | grep ext4
/dev/block/mmcblk0p2 on /data type ext4 (rw,noatime,barrier=0,nobh,data=writeback,noauto_d a_alloc)
/dev/block/stl10 on /dbdata type ext4 (rw,noatime,barrier=0,nobh,data=writeback,noauto_d a_alloc)

2. In addition to that, you can also edit the mount options to include the nobh option, which is a further minor optimization for data=writeback mode.

I personally use the options noatime,barrier=0,nobh,data=writeback. Voodoo already uses some of them like noatime and barrier=0.

I do it using a startup script (you need to know how to use/modify a startup script), with the following commands:

for k in $(busybox mount | grep ext4 | cut -d " " -f3)
do
sync
busybox mount -o remount,barrier=0,nobh $k
done

EDIT: Attached tune2fs that supports ext4. Works on Froyo kernels with ext4 support.
Attached Files
File Type: zip tune2fs-ext4.zip - [Click for QR Code] (111.0 KB, 1601 views)
The Following User Says Thank You to hardcore For This Useful Post: [ Click to Expand ]
 
s88
Old
(Last edited by s88; 26th October 2010 at 06:21 AM.)
#2  
Member
Thanks Meter 2
Posts: 69
Join Date: Nov 2009
I posted the same request in another thread and i though it will be better if i do it here.

I found e2fsprogs-ext4.zip, but not sure if this is the correct zip.

it will be great if you can provide it here.

For others willing to try it, please change the /dev/block/mmcblk0pX to whatever you are using now.
my system is using /dev/block/mmcblk0p4
 
hardcore
Old
#3  
Senior Member - OP
Thanks Meter 8,146
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Quote:
Originally Posted by s88 View Post
I posted the same request in another thread and i though it will be better if i do it here.

I found e2fsprogs-ext4.zip, but not sure if this is the correct zip.

it will be great if you can provide it here.
I've attached it here, it worked for me with the Universal Lagfix Froyo kernel that supports ext4.
 
mdalacu
Old
#4  
mdalacu's Avatar
Senior Member
Thanks Meter 189
Posts: 857
Join Date: Dec 2006
Location: Bucharest
Quote:
Originally Posted by hardcore View Post
I've attached it here, it worked for me with the Universal Lagfix Froyo kernel that supports ext4.
And did you notice any improvements with new mount options?
History: Orange SPV c500, Qtek S200, HTC P3600, HTC Diamond, HTC TouchPro, HTC TouchPro 2, HTC HD2, Samsung Galaxy S, HTC DHD, Samsung Galaxy S2, Samsung Galaxy Note, Asus TF201, Samsung Galaxy Note 10.1, Samsung Galaxy Note 2, Samsung Galaxy N9005].
 
danzel
Old
(Last edited by danzel; 26th October 2010 at 06:34 AM.)
#5  
Member
Thanks Meter 3
Posts: 66
Join Date: May 2004
busybox 1.17.1 says invalid option -o on tune2fs
==
i need the version attached to this thread, busybox version only supports ext2 and ext3
 
s88
Old
#6  
Member
Thanks Meter 2
Posts: 69
Join Date: Nov 2009
Quote:
Originally Posted by danzel View Post
busybox 1.17.1 says invalid option -o on tune2fs
copy tune2fs into /system/xbin and chmod 755
 
chanw4
Old
#7  
Senior Member
Thanks Meter 1
Posts: 134
Join Date: Oct 2010
Write back will cause data loses on crashes and it will increase read time on read miss since you need to write the block back to the main mem before reading a new block.
 
s88
Old
#8  
Member
Thanks Meter 2
Posts: 69
Join Date: Nov 2009
how & where do i edit mount options?
 
hardcore
Old
#9  
Senior Member - OP
Thanks Meter 8,146
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Quote:
Originally Posted by mdalacu View Post
And did you notice any improvements with new mount options?
I didn't do any benchmarks, but in theory it should be better - reduced periodic journal writes (better battery life, flash lifespan and performance).
 
danzel
Old
#10  
Member
Thanks Meter 3
Posts: 66
Join Date: May 2004
I don't know about performance but my SGS feels like a little bit snappier.

Thanks for this info.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Integrate Social Networks Into Your Project With ASNE Library

Social network applications and services have developed into major parts ofour … more

Give Your Android Wear Device a Lock Screen with Lockable

Without a doubt,Android Wear is one of the most frequently talked abouttopics of … more

Forums Added for the LG G Watch R and Samsung Gear S

A little over a week ago, LG “inadvertently” let the world know about the … more

Secrecy App Goes Open Source, New LG Android Wear Device! – XDA Developer TV

Secrecy encryption app goes open source! That and much … more