[HOWTO] Convert ext4 partitions to No-Journaling mode

Search This thread

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
WARNING: This procedure is risky and may result in loss of data.

This is a follow up to findings made in this thread: http://forum.xda-developers.com/showthread.php?t=819580

Many people have been asking for an ext2 lagfix. You can get something similar but (arguably) better: ext4 with no journaling. Ext4 no-journal performs as fast or faster than ext2 because of performance improvements made in ext4.

Quadrant comparison for ext4 /data-only lagfix:
ext4 scores about 1500, ext4 no-journal scores about 1650.

This should work with existing kernels that support ext4 lagfixes. It's tested on a ULFK kernel (SpeedMod).

WARNING: Turning off journaling makes your data more susceptible to getting corrupted, although the risk is small.

Disclaimer: No promises that this will work for you, or that it won't corrupt your data. Try this at your own risk.

Step 0: You start off by applying an ext4 lagfix. If you are already using an ext4 lagfix, you can skip this step.

For ULFK kernels, this is either:
- "Voodoo" ext4 /data
- No-RFS advanced ext4

After the lagfix has been successfully applied and your phone is up and running properly, then you can proceed to convert the ext4 partitions.

Step 1: Make a backup of your data, using CWM (recommended). If anything goes wrong, you can restore the backup later.

Step 2: Download the tune2fs file attached to this post (works for FROYO roms only), and copy it to /data as /data/tune2fs:
adb push tune2fs /sdcard/
adb shell
# su
# cp /sdcard/tune2fs /data/

Procedure if your kernel has ro.debuggable enabled:

Step 3: If your kernel has ro.debuggable enabled, then boot your phone into recovery mode. Then run adb in root mode:
adb root
(wait for adbd to restart)
adb shell

Copy tune2fs to the /tmp folder.

# cp /data/tune2fs /tmp/

If you don't have ro.debuggable enabled, "adb root" will give you an error. Go to Step 3A in the next section.

Step 4: Now in ADB shell, find out which partitions are ext4:
# mount | grep ext4
mount | grep ext4
/dev/block/mmcblk0p2 on /data type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
/dev/block/stl10 on /dbdata type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
/dev/block/stl11 on /cache type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)

In this example, the 3 partitions are:
/dev/block/mmcblk0p2 (/data)
/dev/block/stl10 (/dbdata)
/dev/block/stl11 (/cache)

Repeat Steps 5 to 9 for every partition you want to remove the journal from.

The next steps show the procedure for /dev/block/mmcblk0p2 (/data).

Step 5: Unmount the partition:
umount partition_mount_point
for example:
# umount /data

Step 6: Check if there is a journal:
# /tmp/tune2fs -l /dev/block/mmcblk0p2 | grep features

You should see something like this:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

You should see "has_journal" in the features. It means this partition has a journal.

Step 7: Fsck the partition:
# e2fsck -f /dev/block/mmcblk0p2

Step 8: Remove the journal:
# /tmp/tune2fs -O ^has_journal /dev/block/mmcblk0p2
(this is a capital "O"!)

Step 9: Check if the journal was removed:
# /tmp/tune2fs -l /dev/block/mmcblk0p2 | grep features

You should see something like this:
Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

You should see "has_journal" is NOT there.
Done for this partition.

Step 10: After you've remove the journal from all the partitions you wanted to, shutdown the phone by pressing the power button.

DONE. You only need to do this procedure once and it'll "stick" until the next time you re-format the partition.

--------------------------------------------------

Procedure if you don't have ro.debuggable enabled:

Step 3A: If you kernel does not have ro.debuggable enabled, then you can try doing this using normal adb with su while the phone is running. But this is much more risky.

To lower the risk, do this right after booting, wait for the Media Scan to complete.
adb shell
# su

Step 4A: Now in ADB shell, find out which partitions are ext4:
# mount | grep ext4
mount | grep ext4
/dev/block/mmcblk0p2 on /data type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
/dev/block/stl10 on /dbdata type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
/dev/block/stl11 on /cache type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)

In this example, the 3 partitions are:
/dev/block/mmcblk0p2 (/data)
/dev/block/stl10 (/dbdata)
/dev/block/stl11 (/cache)

Repeat Steps 5A to 8A for every partition you want to remove the journal from.

The next steps show the procedure for /dev/block/mmcblk0p2 (/data).

Step 5A: Check if there is a journal:
# /data/tune2fs -l /dev/block/mmcblk0p2 | grep features

You should see something like this:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

You should see "has_journal" in the features. It means this partition has a journal.

Step 6A: Fsck the partition:
# e2fsck -f /dev/block/mmcblk0p2

WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)?

Answer yes.

Step 7A: Remove the journal:
# /data/tune2fs -O ^has_journal /dev/block/mmcblk0p2
(this is a capital "O"!)

Step 8A: Check if the journal was removed:
# /data/tune2fs -l /dev/block/mmcblk0p2 | grep features

You should see something like this:
Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

You should see "has_journal" is NOT there.
Done for this partition.

Step 9A: After you've remove the journal from all the partitions you wanted to, shutdown the phone by pressing the power button. Reboot the phone and hope everything works.

DONE. You only need to do this procedure once and it'll "stick" until the next time you re-format the partition.
 

Attachments

  • tune2fs-ext4.zip
    111 KB · Views: 945
Last edited:

Cypher_X

Senior Member
Dec 7, 2008
1,625
91
Nice one!
Going to try this tomorrow!

__________________________

Device: GT-I9000 16GB
Rom: Doc's V8 Nude&Raw v3 :cool:
Kernel: Hardcore's Speedmod K9A - 500 Hz
Modem: JPP
Lagfix: No RFS, ext4-ext2, no binds
Tweaks: I/O Sched, Kernel VM Management, Kernel sched
 

danzgrace

Senior Member
Sep 30, 2009
206
43
http://www.mjmwired.net/kernel/Documentation/filesystems/ext4.txt#364

Data Mode
=========
There are 3 different data modes:

* writeback mode
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.

* ordered mode
In data=ordered mode, ext4 only officially journals metadata, but it logically groups metadata information related to data changes with the data blocks into a single unit called a transaction. When it's time to write the new metadata out to disk, the associated data blocks are written first. In general,
this mode performs slightly slower than writeback but significantly faster than journal mode.

* journal mode
data=journal mode provides full data and metadata journaling. All new data is written to the journal first, and then to its final location.
In the event of a crash, the journal can be replayed, bringing both data and metadata into a consistent state. This mode is the slowest except when data needs to be read from and written to disk at the same time where it outperforms all others modes. Currently ext4 does not have delayed allocation support if this data journalling mode is selected.

Applying writeback mode is the best option.
 

danzgrace

Senior Member
Sep 30, 2009
206
43
Hi danzgrace. Those options you quoted are for journaled modes. data=writeback is still a journaled mode.

This procedure is for non-journaled mode (none of the above). Its faster than all of the above because there is *no* journal.

Yes. Just stumbled upon lots of docu about ext4 and you are right about the performance gain when there's no journal involve but kind of risky.

https://ext4.wiki.kernel.org/index.php/Ext4_Howto#.22No_Journaling.22_mode
 

Peacemanibk

Senior Member
Oct 18, 2010
124
7

corgar

Senior Member
Oct 12, 2010
1,062
118
Rome
Can you implement this tweak in speedmod kernel?

Sent from my GT-I9000 using XDA App
 

AnnihilatorSC

Senior Member
Apr 17, 2008
126
3
IMO, keeping the journal, with the default data=ordered option, is a good safety vs. speed compromise.
However, have you tried fiddling with the commit= mount option? The default commit interval is 5 s - this could be what's detrimental to battery life (a wake every 5 seconds). Maybe upping this to 60, or even more, seconds? I myself wouldn't care if it were 5 minutes on a phone, but upping it to one minute should already show a significant battery life increase.
 
Last edited:

hardcore

Senior Member
Sep 12, 2006
3,435
7,990
IMO, keeping the journal, with the default data=ordered option, is a good safety vs. speed compromise.
However, have you tried fiddling with the commit= mount option? The default commit interval is 5 s - this could be what's detrimental to battery life (a wake every 5 seconds). Maybe upping this to 60, or even more, seconds?
I'm not sure if this has any effect when there's no journal. But I guess it's worth a shot.
 

AlexandreT

Senior Member
Aug 5, 2010
262
27
I hope there is a way to do this in a script and apply by update.zip in recovery. Please tell me this can be done...

In general use, just how much faster does this feel? I'm asking because regular ext4 does not feel much faster in general use than RFS using speedmod. Back when I was using JM8 + OCLF, k-9 Email was so much faster.
 

AnnihilatorSC

Senior Member
Apr 17, 2008
126
3
I'm not sure if this has any effect when there's no journal. But I guess it's worth a shot.
It doesn't. But I aim to hang on to the journal. :)
You could try releasing a SpeedMod revision which mounts all ext4 fs's with commit=60. If you do, i'll be sure to report the battery life - the effect should already be obvious to me after a night on battery (I currently lose about 20% battery overnight - no-rfs advanced ext4, w/ defaults).
 

bilboa1

Inactive Recognized Developer
Aug 16, 2010
1,291
683
you can change the commit options by remounting the disk.. in adb or terminal with root..

mount -oremount,data=writeback,journal_async_commit,... /dev/block/... /data (for example)

you will lose it at phone reboot, too - but good for testing
 

danzgrace

Senior Member
Sep 30, 2009
206
43
you can change the commit options by remounting the disk.. in adb or terminal with root..

mount -oremount,data=writeback,journal_async_commit,... /dev/block/... /data (for example)

you will lose it at phone reboot, too - but good for testing

not unless it was on your playlogos hack.
 

danzgrace

Senior Member
Sep 30, 2009
206
43
SpeedMod and ULFK supports init scripts, without the playlogos hack.

Just name the script E_something.sh and place it in /system/etc/init.d/

For example /system/etc/init.d/E_startup.sh

Thanks for the info. imho. I feel more safe putting the script on /data partition so if it fails I just factory reset rather than putting it on /system dir.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    WARNING: This procedure is risky and may result in loss of data.

    This is a follow up to findings made in this thread: http://forum.xda-developers.com/showthread.php?t=819580

    Many people have been asking for an ext2 lagfix. You can get something similar but (arguably) better: ext4 with no journaling. Ext4 no-journal performs as fast or faster than ext2 because of performance improvements made in ext4.

    Quadrant comparison for ext4 /data-only lagfix:
    ext4 scores about 1500, ext4 no-journal scores about 1650.

    This should work with existing kernels that support ext4 lagfixes. It's tested on a ULFK kernel (SpeedMod).

    WARNING: Turning off journaling makes your data more susceptible to getting corrupted, although the risk is small.

    Disclaimer: No promises that this will work for you, or that it won't corrupt your data. Try this at your own risk.

    Step 0: You start off by applying an ext4 lagfix. If you are already using an ext4 lagfix, you can skip this step.

    For ULFK kernels, this is either:
    - "Voodoo" ext4 /data
    - No-RFS advanced ext4

    After the lagfix has been successfully applied and your phone is up and running properly, then you can proceed to convert the ext4 partitions.

    Step 1: Make a backup of your data, using CWM (recommended). If anything goes wrong, you can restore the backup later.

    Step 2: Download the tune2fs file attached to this post (works for FROYO roms only), and copy it to /data as /data/tune2fs:
    adb push tune2fs /sdcard/
    adb shell
    # su
    # cp /sdcard/tune2fs /data/

    Procedure if your kernel has ro.debuggable enabled:

    Step 3: If your kernel has ro.debuggable enabled, then boot your phone into recovery mode. Then run adb in root mode:
    adb root
    (wait for adbd to restart)
    adb shell

    Copy tune2fs to the /tmp folder.

    # cp /data/tune2fs /tmp/

    If you don't have ro.debuggable enabled, "adb root" will give you an error. Go to Step 3A in the next section.

    Step 4: Now in ADB shell, find out which partitions are ext4:
    # mount | grep ext4
    mount | grep ext4
    /dev/block/mmcblk0p2 on /data type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
    /dev/block/stl10 on /dbdata type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
    /dev/block/stl11 on /cache type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)

    In this example, the 3 partitions are:
    /dev/block/mmcblk0p2 (/data)
    /dev/block/stl10 (/dbdata)
    /dev/block/stl11 (/cache)

    Repeat Steps 5 to 9 for every partition you want to remove the journal from.

    The next steps show the procedure for /dev/block/mmcblk0p2 (/data).

    Step 5: Unmount the partition:
    umount partition_mount_point
    for example:
    # umount /data

    Step 6: Check if there is a journal:
    # /tmp/tune2fs -l /dev/block/mmcblk0p2 | grep features

    You should see something like this:
    Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

    You should see "has_journal" in the features. It means this partition has a journal.

    Step 7: Fsck the partition:
    # e2fsck -f /dev/block/mmcblk0p2

    Step 8: Remove the journal:
    # /tmp/tune2fs -O ^has_journal /dev/block/mmcblk0p2
    (this is a capital "O"!)

    Step 9: Check if the journal was removed:
    # /tmp/tune2fs -l /dev/block/mmcblk0p2 | grep features

    You should see something like this:
    Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

    You should see "has_journal" is NOT there.
    Done for this partition.

    Step 10: After you've remove the journal from all the partitions you wanted to, shutdown the phone by pressing the power button.

    DONE. You only need to do this procedure once and it'll "stick" until the next time you re-format the partition.

    --------------------------------------------------

    Procedure if you don't have ro.debuggable enabled:

    Step 3A: If you kernel does not have ro.debuggable enabled, then you can try doing this using normal adb with su while the phone is running. But this is much more risky.

    To lower the risk, do this right after booting, wait for the Media Scan to complete.
    adb shell
    # su

    Step 4A: Now in ADB shell, find out which partitions are ext4:
    # mount | grep ext4
    mount | grep ext4
    /dev/block/mmcblk0p2 on /data type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
    /dev/block/stl10 on /dbdata type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)
    /dev/block/stl11 on /cache type ext4 (rw,noatime,barrier=0,data=writeback,noauto_da_alloc)

    In this example, the 3 partitions are:
    /dev/block/mmcblk0p2 (/data)
    /dev/block/stl10 (/dbdata)
    /dev/block/stl11 (/cache)

    Repeat Steps 5A to 8A for every partition you want to remove the journal from.

    The next steps show the procedure for /dev/block/mmcblk0p2 (/data).

    Step 5A: Check if there is a journal:
    # /data/tune2fs -l /dev/block/mmcblk0p2 | grep features

    You should see something like this:
    Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

    You should see "has_journal" in the features. It means this partition has a journal.

    Step 6A: Fsck the partition:
    # e2fsck -f /dev/block/mmcblk0p2

    WARNING!!! Running e2fsck on a mounted filesystem may cause
    SEVERE filesystem damage.

    Do you really want to continue (y/n)?

    Answer yes.

    Step 7A: Remove the journal:
    # /data/tune2fs -O ^has_journal /dev/block/mmcblk0p2
    (this is a capital "O"!)

    Step 8A: Check if the journal was removed:
    # /data/tune2fs -l /dev/block/mmcblk0p2 | grep features

    You should see something like this:
    Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

    You should see "has_journal" is NOT there.
    Done for this partition.

    Step 9A: After you've remove the journal from all the partitions you wanted to, shutdown the phone by pressing the power button. Reboot the phone and hope everything works.

    DONE. You only need to do this procedure once and it'll "stick" until the next time you re-format the partition.
    1
    Hi guys. can anyone tell how I can convert from non-journaling mode to journaling mode ? Is there any safe procedure / set of commands or do i have to convert back to rfs and then back to ext4 standard.

    tune2fs -j /dev/block/mmcblk0p2 (for data, adjust the device name for other partitions where you removed the journal)