Thursday, March 18, 2010

ext4 disable journal

At one high loaded web project I needed a very fast file system. I decided to use Ext4 with disabled journal (As a google:))).

# Create ext4 fs on /dev/sda10 disk
mkfs.ext4 /dev/sda10

# Enable writeback mode. This mode will typically provide the best ext4 performance.
tune2fs -o journal_data_writeback /dev/sda10

# Delete has_journal option
tune2fs -O ^has_journal /dev/sda10

# Required fsck
e2fsck -f /dev/sda10

# Check fs options
dumpe2fs /dev/sda10 |more

For more performance add fstab opions: data=writeback,noatime,nodiratime
i.e:
/dev/sda10 /opt ext4 defaults,data=writeback,noatime,nodiratime 0 0

Tested at non-boot partition ;)

17 comments:

  1. are you really sure that this disables journaling?
    as far i know journal_data_writeback is just another journal mode which creates journal of meta data only,...

    ReplyDelete
  2. # Delete has_journal option
    tune2fs -O ^has_journal /dev/sda10

    This step disables journal

    ReplyDelete
  3. Or when creating

    mkfs.ext4 -O ^has_journal /dev/sda10

    ReplyDelete
  4. Would you be able to help with the following issue:
    getting more r/w speed from a flash drive install
    http://www.linuxquestions.org/questions/linux-general-1/getting-more-r-w-speed-from-a-flash-drive-install-827164/

    Thanks in advance
    Iain

    ReplyDelete
  5. Could you explain what the purpose of the journal_data_writeback option is once the journal is disabled with the ^has_journal?

    ReplyDelete
  6. I don't remember why I wrote this :)

    ReplyDelete
  7. Oh wow thank for this bit of advice, I am now able to use ZFS on Linux with ext4 instead of ext2. The journaling feature of ext3-4 made ZFS snapshots work incorrectly. Now it works woo hoo!.

    ReplyDelete
  8. how to check the journal is enable or disable ?

    ReplyDelete
  9. dumpe2fs /dev/sda4 |grep 'Filesystem features'
    if has_journal option exist - you have journal

    ReplyDelete
  10. Thanks a lot ..................

    ReplyDelete
  11. I ended up here looking for the right command to remove journaling and thought this thread started some time ago, advice is still very good. My 2c for this are: add "discard" to the mount options in fstab

    /dev/sda10 /opt ext4 defaults,data=writeback,discard,noatime,nodiratime 0 0

    "discard" will enable trimming (see http://sites.google.com/site/lightrush/random-1/howtoconfigureext4toenabletrimforssdsonubuntu)

    Have a good one!

    Marcos Albe

    ReplyDelete
  12. Thanks for posting this. Really helped our BigCouch cluster partitions. Couch is such a IO hog.

    ReplyDelete
  13. In the end of the text, for fstab, "nodiratime" is not necessary, as noatime already includes that option. This can be seen in http://lwn.net/Articles/244941/, http://lwn.net/Articles/245002/, and other texts.

    Roberto

    ReplyDelete
  14. Discard options is default in ext4

    Tejas

    ReplyDelete
  15. Adding discard is a terrible choice if your goal is performance. It is also meaningless for non-flash drives. If you have a flash drive, and performance is the goal, schedule a nightly fstrim cron job on the relevant partitions.

    ReplyDelete
  16. noatime already includes nodiratime, You don't need to specify both.
    https://wiki.archlinux.org/index.php/fstab#atime_options

    ReplyDelete