LG G3 Receives Oversharpening Fix via Modified Kernel

Nothing is perfect, as they say. No matter how alluring or seemingly perfect, … more

APKTool Updated with Android Lollipop Support

One of the beauties of Android is the level of flexibility we have over our devices. Whether … more

Lollipop Leak for Sprint Galaxy S5, TWRP for Micromax Canvas Magnus – XDA TV

Android 5.0 Lollipop has been leaked for the Sprint … more

Velocity is Like OpenTable on Steroids

We all enjoy a night out with friends or our significant other from time to time. However, there is … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[HOWTO] Optimal ext4 mount options

OP hardcore

26th October 2010, 06:55 AM   |  #1  
OP Senior Member
Thanks Meter: 8,152
 
3,435 posts
Join Date:Joined: Sep 2006
Donate to Me
More
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, 1657 views)
Last edited by hardcore; 26th October 2010 at 10:34 AM.
The Following User Says Thank You to hardcore For This Useful Post: [ View ]
26th October 2010, 07:03 AM   |  #2  
Member
Thanks Meter: 2
 
69 posts
Join Date:Joined: 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
Last edited by s88; 26th October 2010 at 07:21 AM.
26th October 2010, 07:23 AM   |  #3  
OP Senior Member
Thanks Meter: 8,152
 
3,435 posts
Join Date:Joined: Sep 2006
Donate to Me
More
Quote:
Originally Posted by s88

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.
26th October 2010, 07:25 AM   |  #4  
mdalacu's Avatar
Senior Member
Flag Bucharest
Thanks Meter: 191
 
874 posts
Join Date:Joined: Dec 2006
Donate to Me
More
Quote:
Originally Posted by hardcore

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?
26th October 2010, 07:28 AM   |  #5  
Member
Thanks Meter: 3
 
66 posts
Join Date:Joined: 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
Last edited by danzel; 26th October 2010 at 07:34 AM.
26th October 2010, 07:35 AM   |  #6  
Member
Thanks Meter: 2
 
69 posts
Join Date:Joined: Nov 2009
Quote:
Originally Posted by danzel

busybox 1.17.1 says invalid option -o on tune2fs

copy tune2fs into /system/xbin and chmod 755
26th October 2010, 07:44 AM   |  #7  
Senior Member
Thanks Meter: 1
 
134 posts
Join Date:Joined: Oct 2010
More
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.
26th October 2010, 07:53 AM   |  #8  
Member
Thanks Meter: 2
 
69 posts
Join Date:Joined: Nov 2009
how & where do i edit mount options?
26th October 2010, 08:13 AM   |  #9  
OP Senior Member
Thanks Meter: 8,152
 
3,435 posts
Join Date:Joined: Sep 2006
Donate to Me
More
Quote:
Originally Posted by mdalacu

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).
26th October 2010, 08:14 AM   |  #10  
Member
Thanks Meter: 3
 
66 posts
Join Date:Joined: May 2004
Thumbs up
I don't know about performance but my SGS feels like a little bit snappier.

Thanks for this info.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes